Page MenuHomePhabricator

[clang] Traverse enum integer-base specifiers in RAV
ClosedPublic

Authored by kadircet on Oct 6 2021, 5:58 AM.

Details

Summary

Visit enum integer-base specifiers explicitly written in the code.

This is achieved by:

  • traversing the typeloc for integer-base on enum decls when they are spelled in the code (similar to base-specifiers for CXXRecordDecls).
  • Visiting the typesourceinfo for integer-base in libindex, similar to base-specifiers.

Diff Detail

Event Timeline

kadircet created this revision.Oct 6 2021, 5:58 AM
kadircet requested review of this revision.Oct 6 2021, 5:58 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 6 2021, 5:58 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
kadircet updated this revision to Diff 377527.Oct 6 2021, 6:48 AM
  • Fix tests
hokein added a comment.Oct 6 2021, 7:03 AM

the RAV change looks good.

I think it might be worth to split this patch (one for RAV, one for libindex).

clang/include/clang/AST/RecursiveASTVisitor.h
1866

we have unittests for RAV, they are in clang/unittests/Tooling/RecursiveASTVisitorTests/, but unfortunately, we don't have one for enum decl, we can create one.

clang/lib/Index/IndexTypeSourceInfo.cpp
310 ↗(On Diff #377515)

this seem to work if the D is a definition, I think it won't report the reference if the enum decl is a declaration.

typedef int MyTypedef;
enum Foo : MyTypedef;
clang/unittests/Index/IndexTests.cpp
387 ↗(On Diff #377515)

This seems to be a copy-paste error.

kadircet updated this revision to Diff 377652.Oct 6 2021, 1:04 PM
kadircet marked 3 inline comments as done.
  • split changes in libindex
  • fix the issue with non-traversal of forward-decls
  • add unittests into RAV
sammccall accepted this revision.Oct 6 2021, 1:52 PM
sammccall added inline comments.
clang/unittests/AST/RecursiveASTVisitorTest.cpp
130

Update/remove comment?

This revision is now accepted and ready to land.Oct 6 2021, 1:52 PM