[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.
This revision was automatically updated to reflect the committed changes. Closed by commit rL363897: [analyzer] exploded-graph-rewriter: Fix escaping StringRegions. (authored by dergachev, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D63519?vs=205449=205705#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63519/new/ https://reviews.llvm.org/D63519 Files: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c === --- cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c @@ -0,0 +1,18 @@ +// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg. +// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-dump-egraph=%t.dot %s +// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s + +// FIXME: Substitution doesn't seem to work on Windows. +// UNSUPPORTED: system-windows + +void string_region_escapes() { + // CHECK: Store: + // CHECK-SAME: foo0 + // CHECK-SAME: Element\{"foo",0 S64b,char\} + // CHECK: Environment: + // CHECK-SAME: "foo" + // CHECK-SAME: Element\{"foo",0 S64b,char\} + const char *const foo = "foo"; +} Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg === --- cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg @@ -15,4 +15,4 @@ config.clang_src_dir, 'utils', 'analyzer') -config.suffixes = ['.dot'] +config.suffixes.add('.dot') Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -210,6 +210,7 @@ void printJson(raw_ostream , const char *NL = "\n", unsigned int Space = 0, bool IsDot = false) const { for (iterator I = begin(); I != end(); ++I) { + // TODO: We might need a .printJson for I.getKey() as well. Indent(Out, Space, IsDot) << "{ \"cluster\": \"" << I.getKey() << "\", \"pointer\": \"" << (const void *)I.getKey() << "\", \"items\": [" << NL; @@ -217,8 +218,9 @@ ++Space; const ClusterBindings = I.getData(); for (ClusterBindings::iterator CI = CB.begin(); CI != CB.end(); ++CI) { -Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": \"" - << CI.getData() << "\" }"; +Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": "; +CI.getData().printJson(Out, /*AddQuotes=*/true); +Out << " }"; if (std::next(CI) != CB.end()) Out << ','; Out << NL; Index: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py === --- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py +++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py @@ -199,6 +199,7 @@ .replace('\\"', '"') \ .replace('\\{', '{') \ .replace('\\}', '}') \ +.replace('', '\\') \ .replace('\\<', '<') \ .replace('\\>', '>') \ .rstrip(',') Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c === --- cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c @@ -0,0 +1,18 @@ +// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg. +// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-dump-egraph=%t.dot %s +// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s + +// FIXME: Substitution doesn't seem to work on Windows. +// UNSUPPORTED: system-windows + +void string_region_escapes() { + // CHECK: Store: + // CHECK-SAME: foo0 + // CHECK-SAME: Element\{"foo",0 S64b,char\} + // CHECK: Environment: + // CHECK-SAME: "foo" + // CHECK-SAME: Element\{"foo",0 S64b,char\} + const char *const
[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.
NoQ updated this revision to Diff 205449. NoQ added a comment. Oh, right, thanks! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63519/new/ https://reviews.llvm.org/D63519 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/test/Analysis/exploded-graph-rewriter/escapes.c clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg clang/utils/analyzer/exploded-graph-rewriter.py Index: clang/utils/analyzer/exploded-graph-rewriter.py === --- clang/utils/analyzer/exploded-graph-rewriter.py +++ clang/utils/analyzer/exploded-graph-rewriter.py @@ -284,6 +284,7 @@ .replace('\\"', '"') \ .replace('\\{', '{') \ .replace('\\}', '}') \ +.replace('', '\\') \ .replace('\\<', '<') \ .replace('\\>', '>') \ .rstrip(',') Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg === --- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg +++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg @@ -15,4 +15,4 @@ config.clang_src_dir, 'utils', 'analyzer') -config.suffixes = ['.dot'] +config.suffixes.add('.dot') Index: clang/test/Analysis/exploded-graph-rewriter/escapes.c === --- /dev/null +++ clang/test/Analysis/exploded-graph-rewriter/escapes.c @@ -0,0 +1,18 @@ +// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg. +// RUN: %clang_cc1 -analyze -analyzer-checker=core \ +// RUN: -analyzer-dump-egraph=%t.dot %s +// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s + +// FIXME: Substitution doesn't seem to work on Windows. +// UNSUPPORTED: system-windows + +void string_region_escapes() { + // CHECK: const char *const foo = "foo"; + // CHECK-SAME: Store: + // CHECK-SAME: foo0 + // CHECK-SAME: Element\{"foo",0 S64b,char\} + // CHECK-SAME: Environment: + // CHECK-SAME: "foo" + // CHECK-SAME: Element\{"foo",0 S64b,char\} + const char *const foo = "foo"; +} Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp === --- clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -210,6 +210,7 @@ void printJson(raw_ostream , const char *NL = "\n", unsigned int Space = 0, bool IsDot = false) const { for (iterator I = begin(); I != end(); ++I) { + // TODO: We might need a .printJson for I.getKey() as well. Indent(Out, Space, IsDot) << "{ \"cluster\": \"" << I.getKey() << "\", \"pointer\": \"" << (const void *)I.getKey() << "\", \"items\": [" << NL; @@ -217,8 +218,9 @@ ++Space; const ClusterBindings = I.getData(); for (ClusterBindings::iterator CI = CB.begin(); CI != CB.end(); ++CI) { -Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": \"" - << CI.getData() << "\" }"; +Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": "; +CI.getData().printJson(Out, /*AddQuotes=*/true); +Out << " }"; if (std::next(CI) != CB.end()) Out << ','; Out << NL; Index: clang/utils/analyzer/exploded-graph-rewriter.py === --- clang/utils/analyzer/exploded-graph-rewriter.py +++ clang/utils/analyzer/exploded-graph-rewriter.py @@ -284,6 +284,7 @@ .replace('\\"', '"') \ .replace('\\{', '{') \ .replace('\\}', '}') \ +.replace('', '\\') \ .replace('\\<', '<') \ .replace('\\>', '>') \ .rstrip(',') Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg === --- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg +++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg @@ -15,4 +15,4 @@ config.clang_src_dir, 'utils', 'analyzer') -config.suffixes = ['.dot'] +config.suffixes.add('.dot') Index: clang/test/Analysis/exploded-graph-rewriter/escapes.c === --- /dev/null +++
[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.
Charusso accepted this revision. Charusso marked an inline comment as done. Charusso added a comment. This revision is now accepted and ready to land. Thanks! Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:222 +Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": "; +CI.getData().printJson(Out, true); +Out << " }"; Could you inject `/*AddQuotes=*/`? Comment at: clang/test/Analysis/exploded-graph-rewriter/escapes.c:3 +// RUN: %clang_cc1 -analyze -analyzer-checker=core \ +// RUN: -analyzer-dump-egraph=%t.dot %s +// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s I like that styling. Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:287 .replace('\\}', '}') \ +.replace('', '\\') \ .replace('\\<', '<') \ I think this is the correct approach. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63519/new/ https://reviews.llvm.org/D63519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.
NoQ created this revision. NoQ added a reviewer: Charusso. Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun. Herald added a project: clang. Additionally, add a forgotten escape for Store values. Repository: rC Clang https://reviews.llvm.org/D63519 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/test/Analysis/exploded-graph-rewriter/escapes.c clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg clang/utils/analyzer/exploded-graph-rewriter.py Index: clang/utils/analyzer/exploded-graph-rewriter.py === --- clang/utils/analyzer/exploded-graph-rewriter.py +++ clang/utils/analyzer/exploded-graph-rewriter.py @@ -284,6 +284,7 @@ .replace('\\"', '"') \ .replace('\\{', '{') \ .replace('\\}', '}') \ +.replace('', '\\') \ .replace('\\<', '<') \ .replace('\\>', '>') \ .rstrip(',') Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg === --- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg +++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg @@ -15,4 +15,4 @@ config.clang_src_dir, 'utils', 'analyzer') -config.suffixes = ['.dot'] +config.suffixes.add('.dot') Index: clang/test/Analysis/exploded-graph-rewriter/escapes.c === --- /dev/null +++ clang/test/Analysis/exploded-graph-rewriter/escapes.c @@ -0,0 +1,18 @@ +// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg. +// RUN: %clang_cc1 -analyze -analyzer-checker=core \ +// RUN: -analyzer-dump-egraph=%t.dot %s +// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s + +// FIXME: Substitution doesn't seem to work on Windows. +// UNSUPPORTED: system-windows + +void string_region_escapes() { + // CHECK: const char *const foo = "foo"; + // CHECK-SAME: Store: + // CHECK-SAME: foo0 + // CHECK-SAME: Element\{"foo",0 S64b,char\} + // CHECK-SAME: Environment: + // CHECK-SAME: "foo" + // CHECK-SAME: Element\{"foo",0 S64b,char\} + const char *const foo = "foo"; +} Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp === --- clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -210,6 +210,7 @@ void printJson(raw_ostream , const char *NL = "\n", unsigned int Space = 0, bool IsDot = false) const { for (iterator I = begin(); I != end(); ++I) { + // TODO: We might need a .printJson for I.getKey() as well. Indent(Out, Space, IsDot) << "{ \"cluster\": \"" << I.getKey() << "\", \"pointer\": \"" << (const void *)I.getKey() << "\", \"items\": [" << NL; @@ -217,8 +218,9 @@ ++Space; const ClusterBindings = I.getData(); for (ClusterBindings::iterator CI = CB.begin(); CI != CB.end(); ++CI) { -Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": \"" - << CI.getData() << "\" }"; +Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": "; +CI.getData().printJson(Out, true); +Out << " }"; if (std::next(CI) != CB.end()) Out << ','; Out << NL; Index: clang/utils/analyzer/exploded-graph-rewriter.py === --- clang/utils/analyzer/exploded-graph-rewriter.py +++ clang/utils/analyzer/exploded-graph-rewriter.py @@ -284,6 +284,7 @@ .replace('\\"', '"') \ .replace('\\{', '{') \ .replace('\\}', '}') \ +.replace('', '\\') \ .replace('\\<', '<') \ .replace('\\>', '>') \ .rstrip(',') Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg === --- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg +++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg @@ -15,4 +15,4 @@ config.clang_src_dir, 'utils', 'analyzer') -config.suffixes = ['.dot'] +config.suffixes.add('.dot') Index: