From e7f994058277d0f00a6f6a8a9c21071ccb1679ef Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Thu, 9 Nov 2017 17:29:59 +0100 Subject: [PATCH] logic: add filename info to static global variables (issue #514) --- .../Bullet3Common_b3AlignedAllocator.txt | 40 +++++++-------- .../Bullet3Common_b3Logging.txt | 50 +++++++++---------- .../Bullet3Common_b3Vector3.txt | 8 +-- src/lib_cxx/CMakeLists.txt | 4 +- .../data/parser/cxx/CommentHandler.cpp | 2 +- src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp | 2 +- .../cxx/CxxAstVisitorComponentIndexer.cpp | 33 ++---------- .../cxx/CxxAstVisitorComponentIndexer.h | 1 - .../data/parser/cxx/CxxDiagnosticConsumer.cpp | 2 +- .../data/parser/cxx/PreprocessorCallbacks.cpp | 2 +- .../cxx/name_resolver/CxxDeclNameResolver.cpp | 36 ++++++++++++- ...lityCxxAstVisitor.cpp => utilityClang.cpp} | 44 +++++++++++++--- ...{utilityCxxAstVisitor.h => utilityClang.h} | 9 ++-- src/test/CxxParserTestSuite.h | 33 ++++++++++++ 14 files changed, 168 insertions(+), 98 deletions(-) rename src/lib_cxx/data/parser/cxx/{utilityCxxAstVisitor.cpp => utilityClang.cpp} (69%) rename src/lib_cxx/data/parser/cxx/{utilityCxxAstVisitor.h => utilityClang.h} (61%) diff --git a/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3AlignedAllocator.txt b/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3AlignedAllocator.txt index 0e83892e..e5f3da75 100644 --- a/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3AlignedAllocator.txt +++ b/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3AlignedAllocator.txt @@ -951,12 +951,12 @@ REFERENCE_TYPE_USAGE static void b3FreeDefault(void *) -> void [b3AlignedAllocat SYMBOL_FUNCTION void free(void *) REFERENCE_CALL static void b3FreeDefault(void *) -> void free(void *) [b3AlignedAllocator.cpp <29:2 29:5>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<27:33> [b3AlignedAllocator.cpp <29:7 29:9>] -SYMBOL_GLOBAL_VARIABLE b3AllocFunc * b3s_allocFunc [b3AlignedAllocator.cpp <32:21 32:33>] -REFERENCE_TYPE_USAGE b3AllocFunc * b3s_allocFunc -> b3AllocFunc [b3AlignedAllocator.cpp <32:8 32:18>] -REFERENCE_USAGE b3AllocFunc * b3s_allocFunc -> static void * b3AllocDefault(size_t) [b3AlignedAllocator.cpp <32:37 32:50>] -SYMBOL_GLOBAL_VARIABLE b3FreeFunc * b3s_freeFunc [b3AlignedAllocator.cpp <33:20 33:31>] -REFERENCE_TYPE_USAGE b3FreeFunc * b3s_freeFunc -> b3FreeFunc [b3AlignedAllocator.cpp <33:8 33:17>] -REFERENCE_USAGE b3FreeFunc * b3s_freeFunc -> static void b3FreeDefault(void *) [b3AlignedAllocator.cpp <33:35 33:47>] +SYMBOL_GLOBAL_VARIABLE b3AllocFunc * b3s_allocFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <32:21 32:33>] +REFERENCE_TYPE_USAGE b3AllocFunc * b3s_allocFunc (b3AlignedAllocator.cpp) -> b3AllocFunc [b3AlignedAllocator.cpp <32:8 32:18>] +REFERENCE_USAGE b3AllocFunc * b3s_allocFunc (b3AlignedAllocator.cpp) -> static void * b3AllocDefault(size_t) [b3AlignedAllocator.cpp <32:37 32:50>] +SYMBOL_GLOBAL_VARIABLE b3FreeFunc * b3s_freeFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <33:20 33:31>] +REFERENCE_TYPE_USAGE b3FreeFunc * b3s_freeFunc (b3AlignedAllocator.cpp) -> b3FreeFunc [b3AlignedAllocator.cpp <33:8 33:17>] +REFERENCE_USAGE b3FreeFunc * b3s_freeFunc (b3AlignedAllocator.cpp) -> static void b3FreeDefault(void *) [b3AlignedAllocator.cpp <33:35 33:47>] SYMBOL_FUNCTION static void * b3AlignedAllocDefault(size_t, int) [b3AlignedAllocator.cpp <66:1 <66:21 66:41> 78:1>] REFERENCE_TYPE_USAGE static void * b3AlignedAllocDefault(size_t, int) -> void [b3AlignedAllocator.cpp <66:15 66:18>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<66:50> [b3AlignedAllocator.cpp <66:50 66:53>] @@ -969,7 +969,7 @@ LOCAL_SYMBOL: b3AlignedAllocator.cpp<69:9> [b3AlignedAllocator.cpp <69:9 69:12>] REFERENCE_TYPE_USAGE static void * b3AlignedAllocDefault(size_t, int) -> char [b3AlignedAllocator.cpp <69:3 69:6>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<69:9> [b3AlignedAllocator.cpp <70:3 70:6>] REFERENCE_TYPE_USAGE static void * b3AlignedAllocDefault(size_t, int) -> char [b3AlignedAllocator.cpp <70:11 70:14>] -REFERENCE_USAGE static void * b3AlignedAllocDefault(size_t, int) -> b3AllocFunc * b3s_allocFunc [b3AlignedAllocator.cpp <70:18 70:30>] +REFERENCE_USAGE static void * b3AlignedAllocDefault(size_t, int) -> b3AllocFunc * b3s_allocFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <70:18 70:30>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<66:50> [b3AlignedAllocator.cpp <70:32 70:35>] REFERENCE_TYPE_USAGE static void * b3AlignedAllocDefault(size_t, int) -> void [b3AlignedAllocator.cpp <70:46 70:49>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<66:60> [b3AlignedAllocator.cpp <70:57 70:65>] @@ -998,25 +998,25 @@ LOCAL_SYMBOL: b3AlignedAllocator.cpp<80:47> [b3AlignedAllocator.cpp <84:7 84:9>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<82:9> [b3AlignedAllocator.cpp <85:5 85:8>] REFERENCE_TYPE_USAGE static void b3AlignedFreeDefault(void *) -> void [b3AlignedAllocator.cpp <85:15 85:18>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<80:47> [b3AlignedAllocator.cpp <85:24 85:26>] -REFERENCE_USAGE static void b3AlignedFreeDefault(void *) -> b3FreeFunc * b3s_freeFunc [b3AlignedAllocator.cpp <86:5 86:16>] +REFERENCE_USAGE static void b3AlignedFreeDefault(void *) -> b3FreeFunc * b3s_freeFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <86:5 86:16>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<82:9> [b3AlignedAllocator.cpp <86:18 86:21>] -SYMBOL_GLOBAL_VARIABLE b3AlignedAllocFunc * b3s_alignedAllocFunc [b3AlignedAllocator.cpp <92:28 92:47>] -REFERENCE_TYPE_USAGE b3AlignedAllocFunc * b3s_alignedAllocFunc -> b3AlignedAllocFunc [b3AlignedAllocator.cpp <92:8 92:25>] -REFERENCE_USAGE b3AlignedAllocFunc * b3s_alignedAllocFunc -> static void * b3AlignedAllocDefault(size_t, int) [b3AlignedAllocator.cpp <92:51 92:71>] -SYMBOL_GLOBAL_VARIABLE b3AlignedFreeFunc * b3s_alignedFreeFunc [b3AlignedAllocator.cpp <93:27 93:45>] -REFERENCE_TYPE_USAGE b3AlignedFreeFunc * b3s_alignedFreeFunc -> b3AlignedFreeFunc [b3AlignedAllocator.cpp <93:8 93:24>] -REFERENCE_USAGE b3AlignedFreeFunc * b3s_alignedFreeFunc -> static void b3AlignedFreeDefault(void *) [b3AlignedAllocator.cpp <93:49 93:68>] +SYMBOL_GLOBAL_VARIABLE b3AlignedAllocFunc * b3s_alignedAllocFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <92:28 92:47>] +REFERENCE_TYPE_USAGE b3AlignedAllocFunc * b3s_alignedAllocFunc (b3AlignedAllocator.cpp) -> b3AlignedAllocFunc [b3AlignedAllocator.cpp <92:8 92:25>] +REFERENCE_USAGE b3AlignedAllocFunc * b3s_alignedAllocFunc (b3AlignedAllocator.cpp) -> static void * b3AlignedAllocDefault(size_t, int) [b3AlignedAllocator.cpp <92:51 92:71>] +SYMBOL_GLOBAL_VARIABLE b3AlignedFreeFunc * b3s_alignedFreeFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <93:27 93:45>] +REFERENCE_TYPE_USAGE b3AlignedFreeFunc * b3s_alignedFreeFunc (b3AlignedAllocator.cpp) -> b3AlignedFreeFunc [b3AlignedAllocator.cpp <93:8 93:24>] +REFERENCE_USAGE b3AlignedFreeFunc * b3s_alignedFreeFunc (b3AlignedAllocator.cpp) -> static void b3AlignedFreeDefault(void *) [b3AlignedAllocator.cpp <93:49 93:68>] SYMBOL_FUNCTION void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) [b3AlignedAllocator.cpp <95:1 <95:6 95:35> 99:1>] REFERENCE_TYPE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> void [b3AlignedAllocator.cpp <95:1 95:4>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<95:57> [b3AlignedAllocator.cpp <95:57 95:65>] REFERENCE_TYPE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> b3AlignedAllocFunc [b3AlignedAllocator.cpp <95:37 95:54>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<95:87> [b3AlignedAllocator.cpp <95:87 95:94>] REFERENCE_TYPE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> b3AlignedFreeFunc [b3AlignedAllocator.cpp <95:68 95:84>] -REFERENCE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> b3AlignedAllocFunc * b3s_alignedAllocFunc [b3AlignedAllocator.cpp <97:3 97:22>] +REFERENCE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> b3AlignedAllocFunc * b3s_alignedAllocFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <97:3 97:22>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<95:57> [b3AlignedAllocator.cpp <97:26 97:34>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<95:57> [b3AlignedAllocator.cpp <97:38 97:46>] REFERENCE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> static void * b3AlignedAllocDefault(size_t, int) [b3AlignedAllocator.cpp <97:50 97:70>] -REFERENCE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> b3AlignedFreeFunc * b3s_alignedFreeFunc [b3AlignedAllocator.cpp <98:3 98:21>] +REFERENCE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> b3AlignedFreeFunc * b3s_alignedFreeFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <98:3 98:21>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<95:87> [b3AlignedAllocator.cpp <98:25 98:32>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<95:87> [b3AlignedAllocator.cpp <98:36 98:43>] REFERENCE_USAGE void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *, b3AlignedFreeFunc *) -> static void b3AlignedFreeDefault(void *) [b3AlignedAllocator.cpp <98:47 98:66>] @@ -1026,11 +1026,11 @@ LOCAL_SYMBOL: b3AlignedAllocator.cpp<101:43> [b3AlignedAllocator.cpp <101:43 101 REFERENCE_TYPE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> b3AllocFunc [b3AlignedAllocator.cpp <101:30 101:40>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<101:66> [b3AlignedAllocator.cpp <101:66 101:73>] REFERENCE_TYPE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> b3FreeFunc [b3AlignedAllocator.cpp <101:54 101:63>] -REFERENCE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> b3AllocFunc * b3s_allocFunc [b3AlignedAllocator.cpp <103:3 103:15>] +REFERENCE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> b3AllocFunc * b3s_allocFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <103:3 103:15>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<101:43> [b3AlignedAllocator.cpp <103:19 103:27>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<101:43> [b3AlignedAllocator.cpp <103:31 103:39>] REFERENCE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> static void * b3AllocDefault(size_t) [b3AlignedAllocator.cpp <103:43 103:56>] -REFERENCE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> b3FreeFunc * b3s_freeFunc [b3AlignedAllocator.cpp <104:3 104:14>] +REFERENCE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> b3FreeFunc * b3s_freeFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <104:3 104:14>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<101:66> [b3AlignedAllocator.cpp <104:18 104:25>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<101:66> [b3AlignedAllocator.cpp <104:29 104:36>] REFERENCE_USAGE void b3AlignedAllocSetCustom(b3AllocFunc *, b3FreeFunc *) -> static void b3FreeDefault(void *) [b3AlignedAllocator.cpp <104:40 104:52>] @@ -1044,7 +1044,7 @@ REFERENCE_USAGE void * b3AlignedAllocInternal(size_t, int) -> int b3g_numAligned LOCAL_SYMBOL: b3AlignedAllocator.cpp<162:8> [b3AlignedAllocator.cpp <162:8 162:10>] REFERENCE_TYPE_USAGE void * b3AlignedAllocInternal(size_t, int) -> void [b3AlignedAllocator.cpp <162:2 162:5>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<162:8> [b3AlignedAllocator.cpp <163:2 163:4>] -REFERENCE_USAGE void * b3AlignedAllocInternal(size_t, int) -> b3AlignedAllocFunc * b3s_alignedAllocFunc [b3AlignedAllocator.cpp <163:8 163:27>] +REFERENCE_USAGE void * b3AlignedAllocInternal(size_t, int) -> b3AlignedAllocFunc * b3s_alignedAllocFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <163:8 163:27>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<159:38> [b3AlignedAllocator.cpp <163:29 163:32>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<159:48> [b3AlignedAllocator.cpp <163:35 163:43>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<162:8> [b3AlignedAllocator.cpp <165:9 165:11>] @@ -1054,5 +1054,5 @@ LOCAL_SYMBOL: b3AlignedAllocator.cpp<168:35> [b3AlignedAllocator.cpp <168:35 168 REFERENCE_TYPE_USAGE void b3AlignedFreeInternal(void *) -> void [b3AlignedAllocator.cpp <168:29 168:32>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<168:35> [b3AlignedAllocator.cpp <170:7 170:9>] REFERENCE_USAGE void b3AlignedFreeInternal(void *) -> int b3g_numAlignedFree [b3AlignedAllocator.cpp <175:2 175:19>] -REFERENCE_USAGE void b3AlignedFreeInternal(void *) -> b3AlignedFreeFunc * b3s_alignedFreeFunc [b3AlignedAllocator.cpp <177:2 177:20>] +REFERENCE_USAGE void b3AlignedFreeInternal(void *) -> b3AlignedFreeFunc * b3s_alignedFreeFunc (b3AlignedAllocator.cpp) [b3AlignedAllocator.cpp <177:2 177:20>] LOCAL_SYMBOL: b3AlignedAllocator.cpp<168:35> [b3AlignedAllocator.cpp <177:22 177:24>] diff --git a/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Logging.txt b/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Logging.txt index 02338945..fbc85cea 100644 --- a/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Logging.txt +++ b/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Logging.txt @@ -154,32 +154,32 @@ LOCAL_SYMBOL: b3Logging.cpp<48:44> [b3Logging.cpp <51:21 51:23>] REFERENCE_CALL void b3ErrorMessageFuncDefault(const char *) -> int printf(const char * const) [b3Logging.cpp <53:2 53:7>] LOCAL_SYMBOL: b3Logging.cpp<48:44> [b3Logging.cpp <53:14 53:16>] REFERENCE_CALL void b3ErrorMessageFuncDefault(const char *) -> int fflush(FILE *) [b3Logging.cpp <56:5 56:10>] -SYMBOL_GLOBAL_VARIABLE b3PrintfFunc * b3s_printfFunc [b3Logging.cpp <62:22 62:35>] -REFERENCE_TYPE_USAGE b3PrintfFunc * b3s_printfFunc -> b3PrintfFunc [b3Logging.cpp <62:8 62:19>] -REFERENCE_USAGE b3PrintfFunc * b3s_printfFunc -> void b3PrintfFuncDefault(const char *) [b3Logging.cpp <62:39 62:57>] -SYMBOL_GLOBAL_VARIABLE b3WarningMessageFunc * b3s_warningMessageFunc [b3Logging.cpp <63:30 63:51>] -REFERENCE_TYPE_USAGE b3WarningMessageFunc * b3s_warningMessageFunc -> b3WarningMessageFunc [b3Logging.cpp <63:8 63:27>] -REFERENCE_USAGE b3WarningMessageFunc * b3s_warningMessageFunc -> void b3WarningMessageFuncDefault(const char *) [b3Logging.cpp <63:55 63:81>] -SYMBOL_GLOBAL_VARIABLE b3ErrorMessageFunc * b3s_errorMessageFunc [b3Logging.cpp <64:28 64:47>] -REFERENCE_TYPE_USAGE b3ErrorMessageFunc * b3s_errorMessageFunc -> b3ErrorMessageFunc [b3Logging.cpp <64:8 64:25>] -REFERENCE_USAGE b3ErrorMessageFunc * b3s_errorMessageFunc -> void b3ErrorMessageFuncDefault(const char *) [b3Logging.cpp <64:51 64:75>] +SYMBOL_GLOBAL_VARIABLE b3PrintfFunc * b3s_printfFunc (b3Logging.cpp) [b3Logging.cpp <62:22 62:35>] +REFERENCE_TYPE_USAGE b3PrintfFunc * b3s_printfFunc (b3Logging.cpp) -> b3PrintfFunc [b3Logging.cpp <62:8 62:19>] +REFERENCE_USAGE b3PrintfFunc * b3s_printfFunc (b3Logging.cpp) -> void b3PrintfFuncDefault(const char *) [b3Logging.cpp <62:39 62:57>] +SYMBOL_GLOBAL_VARIABLE b3WarningMessageFunc * b3s_warningMessageFunc (b3Logging.cpp) [b3Logging.cpp <63:30 63:51>] +REFERENCE_TYPE_USAGE b3WarningMessageFunc * b3s_warningMessageFunc (b3Logging.cpp) -> b3WarningMessageFunc [b3Logging.cpp <63:8 63:27>] +REFERENCE_USAGE b3WarningMessageFunc * b3s_warningMessageFunc (b3Logging.cpp) -> void b3WarningMessageFuncDefault(const char *) [b3Logging.cpp <63:55 63:81>] +SYMBOL_GLOBAL_VARIABLE b3ErrorMessageFunc * b3s_errorMessageFunc (b3Logging.cpp) [b3Logging.cpp <64:28 64:47>] +REFERENCE_TYPE_USAGE b3ErrorMessageFunc * b3s_errorMessageFunc (b3Logging.cpp) -> b3ErrorMessageFunc [b3Logging.cpp <64:8 64:25>] +REFERENCE_USAGE b3ErrorMessageFunc * b3s_errorMessageFunc (b3Logging.cpp) -> void b3ErrorMessageFuncDefault(const char *) [b3Logging.cpp <64:51 64:75>] SYMBOL_FUNCTION void b3SetCustomPrintfFunc(b3PrintfFunc *) [b3Logging.cpp <68:1 <68:6 68:26> 71:1>] REFERENCE_TYPE_USAGE void b3SetCustomPrintfFunc(b3PrintfFunc *) -> void [b3Logging.cpp <68:1 68:4>] LOCAL_SYMBOL: b3Logging.cpp<68:42> [b3Logging.cpp <68:42 68:51>] REFERENCE_TYPE_USAGE void b3SetCustomPrintfFunc(b3PrintfFunc *) -> b3PrintfFunc [b3Logging.cpp <68:28 68:39>] -REFERENCE_USAGE void b3SetCustomPrintfFunc(b3PrintfFunc *) -> b3PrintfFunc * b3s_printfFunc [b3Logging.cpp <70:2 70:15>] +REFERENCE_USAGE void b3SetCustomPrintfFunc(b3PrintfFunc *) -> b3PrintfFunc * b3s_printfFunc (b3Logging.cpp) [b3Logging.cpp <70:2 70:15>] LOCAL_SYMBOL: b3Logging.cpp<68:42> [b3Logging.cpp <70:19 70:28>] SYMBOL_FUNCTION void b3SetCustomWarningMessageFunc(b3WarningMessageFunc *) [b3Logging.cpp <72:1 <72:6 72:34> 75:1>] REFERENCE_TYPE_USAGE void b3SetCustomWarningMessageFunc(b3WarningMessageFunc *) -> void [b3Logging.cpp <72:1 72:4>] LOCAL_SYMBOL: b3Logging.cpp<72:50> [b3Logging.cpp <72:50 72:67>] REFERENCE_TYPE_USAGE void b3SetCustomWarningMessageFunc(b3WarningMessageFunc *) -> b3PrintfFunc [b3Logging.cpp <72:36 72:47>] -REFERENCE_USAGE void b3SetCustomWarningMessageFunc(b3WarningMessageFunc *) -> b3WarningMessageFunc * b3s_warningMessageFunc [b3Logging.cpp <74:2 74:23>] +REFERENCE_USAGE void b3SetCustomWarningMessageFunc(b3WarningMessageFunc *) -> b3WarningMessageFunc * b3s_warningMessageFunc (b3Logging.cpp) [b3Logging.cpp <74:2 74:23>] LOCAL_SYMBOL: b3Logging.cpp<72:50> [b3Logging.cpp <74:27 74:44>] SYMBOL_FUNCTION void b3SetCustomErrorMessageFunc(b3ErrorMessageFunc *) [b3Logging.cpp <76:1 <76:6 76:32> 79:1>] REFERENCE_TYPE_USAGE void b3SetCustomErrorMessageFunc(b3ErrorMessageFunc *) -> void [b3Logging.cpp <76:1 76:4>] LOCAL_SYMBOL: b3Logging.cpp<76:48> [b3Logging.cpp <76:48 76:63>] REFERENCE_TYPE_USAGE void b3SetCustomErrorMessageFunc(b3ErrorMessageFunc *) -> b3PrintfFunc [b3Logging.cpp <76:34 76:45>] -REFERENCE_USAGE void b3SetCustomErrorMessageFunc(b3ErrorMessageFunc *) -> b3ErrorMessageFunc * b3s_errorMessageFunc [b3Logging.cpp <78:2 78:21>] +REFERENCE_USAGE void b3SetCustomErrorMessageFunc(b3ErrorMessageFunc *) -> b3ErrorMessageFunc * b3s_errorMessageFunc (b3Logging.cpp) [b3Logging.cpp <78:2 78:21>] LOCAL_SYMBOL: b3Logging.cpp<76:48> [b3Logging.cpp <78:25 78:40>] SYMBOL_FUNCTION void b3OutputPrintfVarArgsInternal(const char *) [b3Logging.cpp <85:1 <85:6 85:34> 97:1>] REFERENCE_TYPE_USAGE void b3OutputPrintfVarArgsInternal(const char *) -> void [b3Logging.cpp <85:1 85:4>] @@ -196,7 +196,7 @@ REFERENCE_CALL void b3OutputPrintfVarArgsInternal(const char *) -> int vsprintf_ LOCAL_SYMBOL: b3Logging.cpp<87:10> [b3Logging.cpp <91:16 91:23>] LOCAL_SYMBOL: b3Logging.cpp<85:48> [b3Logging.cpp <91:52 91:54>] LOCAL_SYMBOL: b3Logging.cpp<88:13> [b3Logging.cpp <91:56 91:62>] -REFERENCE_USAGE void b3OutputPrintfVarArgsInternal(const char *) -> b3PrintfFunc * b3s_printfFunc [b3Logging.cpp <95:10 95:23>] +REFERENCE_USAGE void b3OutputPrintfVarArgsInternal(const char *) -> b3PrintfFunc * b3s_printfFunc (b3Logging.cpp) [b3Logging.cpp <95:10 95:23>] LOCAL_SYMBOL: b3Logging.cpp<87:10> [b3Logging.cpp <95:26 95:33>] LOCAL_SYMBOL: b3Logging.cpp<88:13> [b3Logging.cpp <96:12 96:18>] SYMBOL_FUNCTION void b3OutputWarningMessageVarArgsInternal(const char *) [b3Logging.cpp <98:1 <98:6 98:42> 110:1>] @@ -213,7 +213,7 @@ REFERENCE_CALL void b3OutputWarningMessageVarArgsInternal(const char *) -> int v LOCAL_SYMBOL: b3Logging.cpp<100:10> [b3Logging.cpp <104:16 104:23>] LOCAL_SYMBOL: b3Logging.cpp<98:56> [b3Logging.cpp <104:52 104:54>] LOCAL_SYMBOL: b3Logging.cpp<101:13> [b3Logging.cpp <104:56 104:62>] -REFERENCE_USAGE void b3OutputWarningMessageVarArgsInternal(const char *) -> b3WarningMessageFunc * b3s_warningMessageFunc [b3Logging.cpp <108:10 108:31>] +REFERENCE_USAGE void b3OutputWarningMessageVarArgsInternal(const char *) -> b3WarningMessageFunc * b3s_warningMessageFunc (b3Logging.cpp) [b3Logging.cpp <108:10 108:31>] LOCAL_SYMBOL: b3Logging.cpp<100:10> [b3Logging.cpp <108:34 108:41>] LOCAL_SYMBOL: b3Logging.cpp<101:13> [b3Logging.cpp <109:12 109:18>] SYMBOL_FUNCTION void b3OutputErrorMessageVarArgsInternal(const char *) [b3Logging.cpp <111:1 <111:6 111:40> 125:1>] @@ -230,7 +230,7 @@ REFERENCE_CALL void b3OutputErrorMessageVarArgsInternal(const char *) -> int vsp LOCAL_SYMBOL: b3Logging.cpp<114:10> [b3Logging.cpp <118:16 118:23>] LOCAL_SYMBOL: b3Logging.cpp<111:54> [b3Logging.cpp <118:52 118:54>] LOCAL_SYMBOL: b3Logging.cpp<115:13> [b3Logging.cpp <118:56 118:62>] -REFERENCE_USAGE void b3OutputErrorMessageVarArgsInternal(const char *) -> b3ErrorMessageFunc * b3s_errorMessageFunc [b3Logging.cpp <122:10 122:29>] +REFERENCE_USAGE void b3OutputErrorMessageVarArgsInternal(const char *) -> b3ErrorMessageFunc * b3s_errorMessageFunc (b3Logging.cpp) [b3Logging.cpp <122:10 122:29>] LOCAL_SYMBOL: b3Logging.cpp<114:10> [b3Logging.cpp <122:32 122:39>] LOCAL_SYMBOL: b3Logging.cpp<115:13> [b3Logging.cpp <123:12 123:18>] SYMBOL_FUNCTION void b3EnterProfileZoneDefault(const char *) [b3Logging.cpp <128:1 <128:6 128:30> 130:1>] @@ -239,30 +239,30 @@ LOCAL_SYMBOL: b3Logging.cpp<128:44> [b3Logging.cpp <128:44 128:47>] REFERENCE_TYPE_USAGE void b3EnterProfileZoneDefault(const char *) -> char [b3Logging.cpp <128:38 128:41>] SYMBOL_FUNCTION void b3LeaveProfileZoneDefault() [b3Logging.cpp <131:1 <131:6 131:30> 133:1>] REFERENCE_TYPE_USAGE void b3LeaveProfileZoneDefault() -> void [b3Logging.cpp <131:1 131:4>] -SYMBOL_GLOBAL_VARIABLE b3EnterProfileZoneFunc * b3s_enterFunc [b3Logging.cpp <134:32 134:44>] -REFERENCE_TYPE_USAGE b3EnterProfileZoneFunc * b3s_enterFunc -> b3EnterProfileZoneFunc [b3Logging.cpp <134:8 134:29>] -REFERENCE_USAGE b3EnterProfileZoneFunc * b3s_enterFunc -> void b3EnterProfileZoneDefault(const char *) [b3Logging.cpp <134:48 134:72>] -SYMBOL_GLOBAL_VARIABLE b3LeaveProfileZoneFunc * b3s_leaveFunc [b3Logging.cpp <135:32 135:44>] -REFERENCE_TYPE_USAGE b3LeaveProfileZoneFunc * b3s_leaveFunc -> b3LeaveProfileZoneFunc [b3Logging.cpp <135:8 135:29>] -REFERENCE_USAGE b3LeaveProfileZoneFunc * b3s_leaveFunc -> void b3LeaveProfileZoneDefault() [b3Logging.cpp <135:48 135:72>] +SYMBOL_GLOBAL_VARIABLE b3EnterProfileZoneFunc * b3s_enterFunc (b3Logging.cpp) [b3Logging.cpp <134:32 134:44>] +REFERENCE_TYPE_USAGE b3EnterProfileZoneFunc * b3s_enterFunc (b3Logging.cpp) -> b3EnterProfileZoneFunc [b3Logging.cpp <134:8 134:29>] +REFERENCE_USAGE b3EnterProfileZoneFunc * b3s_enterFunc (b3Logging.cpp) -> void b3EnterProfileZoneDefault(const char *) [b3Logging.cpp <134:48 134:72>] +SYMBOL_GLOBAL_VARIABLE b3LeaveProfileZoneFunc * b3s_leaveFunc (b3Logging.cpp) [b3Logging.cpp <135:32 135:44>] +REFERENCE_TYPE_USAGE b3LeaveProfileZoneFunc * b3s_leaveFunc (b3Logging.cpp) -> b3LeaveProfileZoneFunc [b3Logging.cpp <135:8 135:29>] +REFERENCE_USAGE b3LeaveProfileZoneFunc * b3s_leaveFunc (b3Logging.cpp) -> void b3LeaveProfileZoneDefault() [b3Logging.cpp <135:48 135:72>] SYMBOL_FUNCTION void b3EnterProfileZone(const char *) [b3Logging.cpp <136:1 <136:6 136:23> 139:1>] REFERENCE_TYPE_USAGE void b3EnterProfileZone(const char *) -> void [b3Logging.cpp <136:1 136:4>] LOCAL_SYMBOL: b3Logging.cpp<136:37> [b3Logging.cpp <136:37 136:40>] REFERENCE_TYPE_USAGE void b3EnterProfileZone(const char *) -> char [b3Logging.cpp <136:31 136:34>] -REFERENCE_USAGE void b3EnterProfileZone(const char *) -> b3EnterProfileZoneFunc * b3s_enterFunc [b3Logging.cpp <138:3 138:15>] +REFERENCE_USAGE void b3EnterProfileZone(const char *) -> b3EnterProfileZoneFunc * b3s_enterFunc (b3Logging.cpp) [b3Logging.cpp <138:3 138:15>] LOCAL_SYMBOL: b3Logging.cpp<136:37> [b3Logging.cpp <138:18 138:21>] SYMBOL_FUNCTION void b3LeaveProfileZone() [b3Logging.cpp <140:1 <140:6 140:23> 143:1>] REFERENCE_TYPE_USAGE void b3LeaveProfileZone() -> void [b3Logging.cpp <140:1 140:4>] -REFERENCE_USAGE void b3LeaveProfileZone() -> b3LeaveProfileZoneFunc * b3s_leaveFunc [b3Logging.cpp <142:3 142:15>] +REFERENCE_USAGE void b3LeaveProfileZone() -> b3LeaveProfileZoneFunc * b3s_leaveFunc (b3Logging.cpp) [b3Logging.cpp <142:3 142:15>] SYMBOL_FUNCTION void b3SetCustomEnterProfileZoneFunc(b3EnterProfileZoneFunc *) [b3Logging.cpp <145:1 <145:6 145:36> 148:1>] REFERENCE_TYPE_USAGE void b3SetCustomEnterProfileZoneFunc(b3EnterProfileZoneFunc *) -> void [b3Logging.cpp <145:1 145:4>] LOCAL_SYMBOL: b3Logging.cpp<145:62> [b3Logging.cpp <145:62 145:70>] REFERENCE_TYPE_USAGE void b3SetCustomEnterProfileZoneFunc(b3EnterProfileZoneFunc *) -> b3EnterProfileZoneFunc [b3Logging.cpp <145:38 145:59>] -REFERENCE_USAGE void b3SetCustomEnterProfileZoneFunc(b3EnterProfileZoneFunc *) -> b3EnterProfileZoneFunc * b3s_enterFunc [b3Logging.cpp <147:2 147:14>] +REFERENCE_USAGE void b3SetCustomEnterProfileZoneFunc(b3EnterProfileZoneFunc *) -> b3EnterProfileZoneFunc * b3s_enterFunc (b3Logging.cpp) [b3Logging.cpp <147:2 147:14>] LOCAL_SYMBOL: b3Logging.cpp<145:62> [b3Logging.cpp <147:18 147:26>] SYMBOL_FUNCTION void b3SetCustomLeaveProfileZoneFunc(b3LeaveProfileZoneFunc *) [b3Logging.cpp <149:1 <149:6 149:36> 152:1>] REFERENCE_TYPE_USAGE void b3SetCustomLeaveProfileZoneFunc(b3LeaveProfileZoneFunc *) -> void [b3Logging.cpp <149:1 149:4>] LOCAL_SYMBOL: b3Logging.cpp<149:62> [b3Logging.cpp <149:62 149:70>] REFERENCE_TYPE_USAGE void b3SetCustomLeaveProfileZoneFunc(b3LeaveProfileZoneFunc *) -> b3LeaveProfileZoneFunc [b3Logging.cpp <149:38 149:59>] -REFERENCE_USAGE void b3SetCustomLeaveProfileZoneFunc(b3LeaveProfileZoneFunc *) -> b3LeaveProfileZoneFunc * b3s_leaveFunc [b3Logging.cpp <151:2 151:14>] +REFERENCE_USAGE void b3SetCustomLeaveProfileZoneFunc(b3LeaveProfileZoneFunc *) -> b3LeaveProfileZoneFunc * b3s_leaveFunc (b3Logging.cpp) [b3Logging.cpp <151:2 151:14>] LOCAL_SYMBOL: b3Logging.cpp<149:62> [b3Logging.cpp <151:18 151:26>] diff --git a/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Vector3.txt b/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Vector3.txt index b0a62f9a..23d2f869 100644 --- a/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Vector3.txt +++ b/bin/test/data/CxxIndexSampleProjectsTestSuite/Bullet3/expected_output/Bullet3Common_b3Vector3.txt @@ -968,10 +968,10 @@ SYMBOL_BUILTIN_TYPE float REFERENCE_TYPE_USAGE b3Scalar -> float [b3Scalar.h <263:9 263:13>] SYMBOL_TYPEDEF b3SimdFloat4 [b3Scalar.h <269:16 269:27>] REFERENCE_TYPE_USAGE b3SimdFloat4 -> __m128 [b3Scalar.h <269:9 269:14>] -SYMBOL_GLOBAL_VARIABLE int b3NanMask [b3Scalar.h <276:12 276:20>] -REFERENCE_TYPE_USAGE int b3NanMask -> int [b3Scalar.h <276:8 276:10>] -SYMBOL_GLOBAL_VARIABLE int b3InfinityMask [b3Scalar.h <281:13 281:26>] -REFERENCE_TYPE_USAGE int b3InfinityMask -> int [b3Scalar.h <281:9 281:11>] +SYMBOL_GLOBAL_VARIABLE int b3NanMask (b3Vector3.cpp) [b3Scalar.h <276:12 276:20>] +REFERENCE_TYPE_USAGE int b3NanMask (b3Vector3.cpp) -> int [b3Scalar.h <276:8 276:10>] +SYMBOL_GLOBAL_VARIABLE int b3InfinityMask (b3Vector3.cpp) [b3Scalar.h <281:13 281:26>] +REFERENCE_TYPE_USAGE int b3InfinityMask (b3Vector3.cpp) -> int [b3Scalar.h <281:9 281:11>] SYMBOL_FUNCTION __m128 operator+(const __m128, const __m128) [b3Scalar.h <285:1 <285:15 285:24> 288:1>] REFERENCE_TYPE_USAGE __m128 operator+(const __m128, const __m128) -> __m128 [b3Scalar.h <285:8 285:13>] LOCAL_SYMBOL: b3Scalar.h<285:40> [b3Scalar.h <285:40 285:40>] diff --git a/src/lib_cxx/CMakeLists.txt b/src/lib_cxx/CMakeLists.txt index 384e4c24..76291b96 100644 --- a/src/lib_cxx/CMakeLists.txt +++ b/src/lib_cxx/CMakeLists.txt @@ -72,8 +72,8 @@ add_files( data/parser/cxx/CxxVerboseAstVisitor.h data/parser/cxx/PreprocessorCallbacks.cpp data/parser/cxx/PreprocessorCallbacks.h - data/parser/cxx/utilityCxxAstVisitor.cpp - data/parser/cxx/utilityCxxAstVisitor.h + data/parser/cxx/utilityClang.cpp + data/parser/cxx/utilityClang.h data/storage/StorageTransformationAnonymousTypedef.cpp data/storage/StorageTransformationAnonymousTypedef.h diff --git a/src/lib_cxx/data/parser/cxx/CommentHandler.cpp b/src/lib_cxx/data/parser/cxx/CommentHandler.cpp index d9febfb5..7b7fcb82 100644 --- a/src/lib_cxx/data/parser/cxx/CommentHandler.cpp +++ b/src/lib_cxx/data/parser/cxx/CommentHandler.cpp @@ -1,6 +1,6 @@ #include "data/parser/cxx/CommentHandler.h" -#include "data/parser/cxx/utilityCxxAstVisitor.h" +#include "data/parser/cxx/utilityClang.h" #include "data/parser/ParseLocation.h" #include "data/parser/ParserClient.h" #include "utility/file/FileRegister.h" diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp b/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp index 685d2ff0..141f2dfb 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp @@ -12,7 +12,7 @@ #include "data/parser/cxx/CxxAstVisitorComponentTypeRefKind.h" #include "data/parser/cxx/CxxAstVisitorComponentImplicitCode.h" #include "data/parser/cxx/CxxAstVisitorComponentIndexer.h" -#include "data/parser/cxx/utilityCxxAstVisitor.h" +#include "data/parser/cxx/utilityClang.h" #include "data/parser/ParserClient.h" #include "data/parser/ParseLocation.h" diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp index 289b122d..90e10f32 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp @@ -9,7 +9,7 @@ #include "data/parser/cxx/CxxAstVisitorComponentDeclRefKind.h" #include "data/parser/cxx/CxxAstVisitorComponentTypeRefKind.h" -#include "data/parser/cxx/utilityCxxAstVisitor.h" +#include "data/parser/cxx/utilityClang.h" #include "data/parser/ParseLocation.h" #include "data/parser/ParserClient.h" #include "utility/file/FileRegister.h" @@ -140,7 +140,7 @@ void CxxAstVisitorComponentIndexer::beginTraverseLambdaCapture(clang::LambdaExpr if ((!lambdaExpr->isInitCapture(capture)) && (capture->capturesVariable())) { clang::VarDecl* d = capture->getCapturedVar(); - SymbolKind symbolKind = getSymbolKind(d); + SymbolKind symbolKind = utility::getSymbolKind(d); if (symbolKind == SYMBOL_LOCAL_VARIABLE || symbolKind == SYMBOL_PARAMETER) { if (!d->getNameAsString().empty()) // don't record anonymous parameters @@ -228,7 +228,7 @@ void CxxAstVisitorComponentIndexer::visitVarDecl(clang::VarDecl* d) { if (shouldVisitDecl(d)) { - SymbolKind symbolKind = getSymbolKind(d); + SymbolKind symbolKind = utility::getSymbolKind(d); if (symbolKind == SYMBOL_LOCAL_VARIABLE || symbolKind == SYMBOL_PARAMETER) { if (!d->getNameAsString().empty()) // don't record anonymous parameters @@ -765,33 +765,6 @@ ReferenceKind CxxAstVisitorComponentIndexer::consumeDeclRefContextKind() return refKind; } -SymbolKind CxxAstVisitorComponentIndexer::getSymbolKind(clang::VarDecl* d) -{ - SymbolKind symbolKind = SYMBOL_KIND_MAX; - - if (llvm::isa(d)) - { - symbolKind = SYMBOL_PARAMETER; - } - else if (d->getParentFunctionOrMethod() == NULL) - { - if (d->getAccess() == clang::AS_none) - { - symbolKind = SYMBOL_GLOBAL_VARIABLE; - } - else - { - symbolKind = SYMBOL_FIELD; - } - } - else - { - symbolKind = SYMBOL_LOCAL_VARIABLE; - } - - return symbolKind; -} - bool CxxAstVisitorComponentIndexer::shouldVisitDecl(const clang::Decl* decl) { if (decl) diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.h b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.h index 3be3a5f8..ac7c474f 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.h +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.h @@ -67,7 +67,6 @@ private: ParseLocation getParseLocation(const clang::SourceRange& sourceRange) const; ReferenceKind consumeDeclRefContextKind(); - SymbolKind getSymbolKind(clang::VarDecl* d); bool shouldVisitDecl(const clang::Decl* decl); bool shouldVisitReference(const clang::SourceLocation& referenceLocation, const clang::Decl* contextDecl); diff --git a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp index 371fc1fc..9ca8079d 100644 --- a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp @@ -3,7 +3,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Tooling/Tooling.h" -#include "data/parser/cxx/utilityCxxAstVisitor.h" +#include "data/parser/cxx/utilityClang.h" #include "data/parser/ParseLocation.h" #include "data/parser/ParserClient.h" #include "utility/file/FileRegister.h" diff --git a/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp b/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp index d4012992..94b0d943 100644 --- a/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp +++ b/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp @@ -7,7 +7,7 @@ #include "utility/file/FileSystem.h" #include "utility/file/FileRegister.h" -#include "data/parser/cxx/utilityCxxAstVisitor.h" +#include "data/parser/cxx/utilityClang.h" #include "data/parser/ParserClient.h" #include "data/parser/ParseLocation.h" diff --git a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp index aed077c0..af21352c 100644 --- a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp +++ b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp @@ -8,6 +8,7 @@ #include "data/parser/cxx/name_resolver/CxxSpecifierNameResolver.h" #include "data/parser/cxx/name_resolver/CxxTemplateArgumentNameResolver.h" #include "data/parser/cxx/name_resolver/CxxTypeNameResolver.h" +#include "data/parser/cxx/utilityClang.h" #include "utility/file/FilePath.h" #include "utility/ScopedSwitcher.h" @@ -327,7 +328,40 @@ std::shared_ptr CxxDeclNameResolver::getDeclName(const clang::Named CxxTypeNameResolver typenNameResolver(getIgnoredContextDecls()); typenNameResolver.ignoreContextDecl(varDecl); std::shared_ptr typeName = CxxTypeName::makeUnsolvedIfNull(typenNameResolver.getName(varDecl->getType())); - return std::make_shared(declNameString, std::vector(), typeName, isStatic); + + std::string varName = declNameString; + if (utility::getSymbolKind(varDecl) == SYMBOL_GLOBAL_VARIABLE && + varDecl->getStorageClass() == clang::SC_Static) + { + // if a global variable is static it is only visible in the current translation unit. Therefore if multiple instances of that global variable + // may be generated (one for each translation unit) we add the name of the translation unit's source file. + // If that global variable definition is const, we add the name of the (maybe header) file that variable is defined in instead. This causes + // different instances of the variable that all MUST contain the same value to be merged into a single node in Sourcetrail. + std::string scopeFileName = ""; + { + const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager(); + if (varDecl->getType().isConstQualified()) + { + const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart()); + scopeFileName = FilePath(presumedBegin.getFilename()).fileName(); + } + else + { + clang::FileID fileId = sourceManager.getMainFileID(); + if (fileId.isValid()) + { + const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId); + scopeFileName = FilePath(utility::getFileNameOfFileEntry(fileEntry)).fileName(); + } + } + } + if (!scopeFileName.empty()) + { + varName = declNameString + " (" + scopeFileName + ")"; + } + } + + return std::make_shared(varName, std::vector(), typeName, isStatic); } } diff --git a/src/lib_cxx/data/parser/cxx/utilityCxxAstVisitor.cpp b/src/lib_cxx/data/parser/cxx/utilityClang.cpp similarity index 69% rename from src/lib_cxx/data/parser/cxx/utilityCxxAstVisitor.cpp rename to src/lib_cxx/data/parser/cxx/utilityClang.cpp index fad0a0af..491db72a 100644 --- a/src/lib_cxx/data/parser/cxx/utilityCxxAstVisitor.cpp +++ b/src/lib_cxx/data/parser/cxx/utilityClang.cpp @@ -1,4 +1,4 @@ -#include "data/parser/cxx/utilityCxxAstVisitor.h" +#include "data/parser/cxx/utilityClang.h" #include #include @@ -64,7 +64,7 @@ AccessKind utility::convertAccessSpecifier(clang::AccessSpecifier access) } } -SymbolKind utility::convertTagKind(clang::TagTypeKind tagKind) +SymbolKind utility::convertTagKind(const clang::TagTypeKind tagKind) { switch (tagKind) { @@ -81,17 +81,47 @@ SymbolKind utility::convertTagKind(clang::TagTypeKind tagKind) } } -std::string utility::getFileNameOfFileEntry(const clang::FileEntry* entry) +SymbolKind utility::getSymbolKind(const clang::VarDecl* d) { - std::string fileName = entry->tryGetRealPathName(); - if (fileName.empty()) + SymbolKind symbolKind = SYMBOL_KIND_MAX; + + if (llvm::isa(d)) { - fileName = entry->getName(); + symbolKind = SYMBOL_PARAMETER; + } + else if (d->getParentFunctionOrMethod() == NULL) + { + if (d->getAccess() == clang::AS_none) + { + symbolKind = SYMBOL_GLOBAL_VARIABLE; + } + else + { + symbolKind = SYMBOL_FIELD; + } } else { - fileName = FilePath(entry->getName().str()).parentDirectory().concat(FilePath(FilePath(fileName).fileName())).str(); + symbolKind = SYMBOL_LOCAL_VARIABLE; } + return symbolKind; +} + +std::string utility::getFileNameOfFileEntry(const clang::FileEntry* entry) +{ + std::string fileName = ""; + if (entry) + { + fileName = entry->tryGetRealPathName(); + if (fileName.empty()) + { + fileName = entry->getName(); + } + else + { + fileName = FilePath(entry->getName().str()).parentDirectory().concat(FilePath(FilePath(fileName).fileName())).str(); + } + } return fileName; } diff --git a/src/lib_cxx/data/parser/cxx/utilityCxxAstVisitor.h b/src/lib_cxx/data/parser/cxx/utilityClang.h similarity index 61% rename from src/lib_cxx/data/parser/cxx/utilityCxxAstVisitor.h rename to src/lib_cxx/data/parser/cxx/utilityClang.h index a8b98dcd..20a5d770 100644 --- a/src/lib_cxx/data/parser/cxx/utilityCxxAstVisitor.h +++ b/src/lib_cxx/data/parser/cxx/utilityClang.h @@ -1,5 +1,5 @@ -#ifndef UTILITY_CXX_AST_VISITOR_H -#define UTILITY_CXX_AST_VISITOR_H +#ifndef UTILITY_CLANG_H +#define UTILITY_CLANG_H #include @@ -10,8 +10,9 @@ namespace utility { bool isImplicit(const clang::Decl* d); AccessKind convertAccessSpecifier(clang::AccessSpecifier access); - SymbolKind convertTagKind(clang::TagTypeKind tagKind); + SymbolKind convertTagKind(const clang::TagTypeKind tagKind); + SymbolKind getSymbolKind(const clang::VarDecl* d); std::string getFileNameOfFileEntry(const clang::FileEntry* entry); } -#endif // UTILITY_CXX_AST_VISITOR_H +#endif // UTILITY_CLANG_H diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index 3b202ca8..b2ea679b 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -54,6 +54,39 @@ public: /////////////////////////////////////////////////////////////////////////////// // test finding symbol definitions and declarations + void test_cxx_parser_finds_global_variable_declaration() + { + std::shared_ptr client = parseCode( + "int x;\n" + ); + + TS_ASSERT(utility::containsElement( + client->globalVariables, "int x <1:5 1:5>" + )); + } + + void test_cxx_parser_finds_static_global_variable_declaration() + { + std::shared_ptr client = parseCode( + "static int x;\n" + ); + + TS_ASSERT(utility::containsElement( + client->globalVariables, "int x (input.cc) <1:12 1:12>" + )); + } + + void test_cxx_parser_finds_static_const_global_variable_declaration() + { + std::shared_ptr client = parseCode( + "static const int x;\n" + ); + + TS_ASSERT(utility::containsElement( + client->globalVariables, "const int x (input.cc) <1:18 1:18>" + )); + } + void test_cxx_parser_finds_global_class_definition() { std::shared_ptr client = parseCode(