[AST] Move visibility computations into a class; NFC
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Wed, 9 Aug 2017 04:02:49 +0000 (04:02 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Wed, 9 Aug 2017 04:02:49 +0000 (04:02 +0000)
commit99db3ea6902a3bf86cde37866ba8afd55bada30e
tree109a594d25cb08690b43c747c400f70f80b802ae
parentc06b35c97e65e673530293db1d6931a06cd98396
[AST] Move visibility computations into a class; NFC

This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal
is to cache decl visibility/linkage for the duration of each
visibility+linkage query.

The simplest way I can see to do this is to put the visibility
calculation code that needs to (transitively) access this cache into a
class, which is what this patch does. Actual caching will come in patch
2. (Another way would be to keep the cache in ASTContext + manually
invalidate it or something, but that felt way too subtle to me.)

Caching visibility results across multiple queries seems a bit tricky,
since the user can add visibility attributes ~whenever they want, and
these attributes can apparently have far-reaching effects (e.g. class
visibility extends to its members, ...). Because a cache that's dropped
at the end of each top-level query seems to work nearly as well and
doesn't require any eviction logic, I opted for that design.

llvm-svn: 310436
clang/lib/AST/Decl.cpp
clang/lib/AST/Linkage.h [new file with mode: 0644]
clang/lib/AST/Type.cpp