Given int foo, bar;, TraverseAST reveals this tree:
TranslationUnitDecl - foo - bar
Before this patch, with the TraversalScope set to {foo}, TraverseAST yields:
foo
After this patch it yields:
TranslationUnitDecl - foo
Also, TraverseDecl(TranslationUnitDecl) now respects the traversal scope.
The main effect of this today is that clang-tidy checks that match the
translationUnitDecl(), either in order to traverse it or check
parentage, should work.
I would use a more meaningful name -- it is unclear to me what "trivial" means here without reading the code very hard.
IIUC it distinguishes the conventional case ( a single translation-unit decl) vs the case (where e.g. the TraversalScope is set to main-file decls).