[PATCH] D57208: Replace two RecursiveASTVisitor insantiations with StmtVisitor

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 24 17:06:50 PST 2019


rnk created this revision.
rnk added reviewers: arphaman, rsmith.

RecursiveASTVisitor is very expensive to instantiate and results in
needlessly slow compilation. For these availability check fixits, we
don't need to instantiate the full complexity of the declaration walking
machinery, we can use a plain StmtVisitor.

This change reduces time to compile SemaDeclAttr.cpp and saves object
file size:

  | before   | after

time (s) | 1m7.821s | 0m52.459s
obj (kb) | 13280    | 11364

So, 15s and 1.9 MB of object file. If clang had presubmits checks, I'd
add a check that warned on new inclusions of RecursiveASTVisitor.h.  =/

I won't promise that this doesn't change functionality, since RAV walks
through quite a number of things that StmtVisitor doesn't, like blocks
and lambdas.

I noticed that SemaOpenMP has a very similar utility called
LocalVarRefChecker, so there is definitely some opportunity for
refactoring further after this.


https://reviews.llvm.org/D57208

Files:
  clang/lib/Sema/SemaDeclAttr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57208.183445.patch
Type: text/x-patch
Size: 3469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190125/7b6cc68e/attachment.bin>


More information about the cfe-commits mailing list