[PATCH] D50261: [AST] Remove unnecessary indirections in DeclarationNameTable

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 3 09:37:13 PDT 2018


bricci created this revision.
bricci added reviewers: erichkeane, rsmith, rnk.
bricci added a project: clang.
Herald added a subscriber: cfe-commits.

DeclarationNameTable currently hold 3 void * to
FoldingSet<CXXSpecialName>, FoldingSet<CXXLiteralOperatorIdName>
and FoldingSet<CXXDeductionGuideNameExtra>.

CXXSpecialName,  CXXLiteralOperatorIdName and
CXXDeductionGuideNameExtra are private classes holding extra
information about a "special" declaration name and are in the DeclarationName.cpp
The original intent seems to have been to keep these class private and only expose
DeclarationNameExtra and DeclarationName (the code dates from 2008 and
has not been significantly changed since).

However this make the code less straightforward than necessary because of
the need to have void* in DeclarationNameTable (with 1 of 3 comments wrong)
and to manually allocate/deallocate the FoldingSets.

Moreover removing the extra indirections reduce the run-time of an fsyntax-only on
all of Boost by 2.3% which is not totally unexpected given how frequently this
data structure is used.

Comments:

- For now I just moved the classes which were in DeclarationName.cpp to DeclarationName.h. We could find a way to hide them if desired, eg by stuffing them into a namespace detail or something...
- This requires including Type.h...


Repository:
  rC Clang

https://reviews.llvm.org/D50261

Files:
  include/clang/AST/DeclarationName.h
  lib/AST/DeclarationName.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50261.159025.patch
Type: text/x-patch
Size: 12879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180803/c4e02dec/attachment-0001.bin>


More information about the cfe-commits mailing list