summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/Syntax/Synthesis.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2020-01-14 16:07:11 +0100
committerIlya Biryukov <ibiryukov@google.com>2020-01-14 16:31:08 +0100
commit3b929fe7763570fc1d4a4691a53257a4a0b7760e (patch)
tree4256e18725166442080ba975fd0a3472c07c336c /clang/lib/Tooling/Syntax/Synthesis.cpp
parent9738c757bd9bc2fdca935f2b4e356f1d5e5f3682 (diff)
downloadbcm5719-llvm-3b929fe7763570fc1d4a4691a53257a4a0b7760e.tar.gz
bcm5719-llvm-3b929fe7763570fc1d4a4691a53257a4a0b7760e.zip
[Syntax] Assert invariants on tree structure and fix a bug in mutations
Add checks for some structural invariants when building and mutating the syntax trees. Fix a bug failing the invariants after mutations: the parent of nodes added into the tree was null.
Diffstat (limited to 'clang/lib/Tooling/Syntax/Synthesis.cpp')
-rw-r--r--clang/lib/Tooling/Syntax/Synthesis.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Tooling/Syntax/Synthesis.cpp b/clang/lib/Tooling/Syntax/Synthesis.cpp
index 73ae71f9a6c..cbd9579f4f0 100644
--- a/clang/lib/Tooling/Syntax/Synthesis.cpp
+++ b/clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -26,7 +26,9 @@ clang::syntax::Leaf *syntax::createPunctuation(clang::syntax::Arena &A,
.second;
assert(Tokens.size() == 1);
assert(Tokens.front().kind() == K);
- return new (A.allocator()) clang::syntax::Leaf(Tokens.begin());
+ auto *L = new (A.allocator()) clang::syntax::Leaf(Tokens.begin());
+ L->assertInvariants();
+ return L;
}
clang::syntax::EmptyStatement *
@@ -34,5 +36,6 @@ syntax::createEmptyStatement(clang::syntax::Arena &A) {
auto *S = new (A.allocator()) clang::syntax::EmptyStatement;
FactoryImpl::prependChildLowLevel(S, createPunctuation(A, clang::tok::semi),
NodeRole::Unknown);
+ S->assertInvariants();
return S;
}
OpenPOWER on IntegriCloud