[ASTImporter] Add basic support for comparing Stmts and compare function bodies
authorRaphael Isemann <teemperor@gmail.com>
Sat, 12 Sep 2020 19:49:48 +0000 (21:49 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Sun, 13 Sep 2020 16:25:04 +0000 (18:25 +0200)
commitc0bcd11068fc13e45b253c6c315882097f94c121
tree7bce2aa7e35ca4c1fbdd46519093b33904d4e1f4
parenta4c535198643d1541b19f37a468c885a7baa7605
[ASTImporter] Add basic support for comparing Stmts and compare function bodies

Right now the ASTImporter assumes for most Expr nodes that they are always equal
which leads to non-compatible declarations ending up being merged. This patch
adds the basic framework for comparing Stmts (and with that also Exprs) and
implements the custom checks for a few Stmt subclasses. I'll implement the
remaining subclasses in follow up patches (mostly because there are a lot of
subclasses and some of them require further changes like having GNU language in
the testing framework)

The motivation for this is that in LLDB we try to import libc++ source code and
some of the types we are importing there contain expressions (e.g. because they
use `enable_if<expr>`), so those declarations are currently merged even if they
are completely different (e.g. `enable_if<value> ...` and `enable_if<!value>
...` are currently considered equal which is clearly not true).

Reviewed By: martong, balazske

Differential Revision: https://reviews.llvm.org/D87444
clang/include/clang/AST/ASTStructuralEquivalence.h
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp