Hi, I would like to use clang-tidy to analyze the inheritance relationship between classes defined in a c++ file. I was going to use
“it=CXXRecordDecl->bases_begin()—CXXRecordDecl->bases_end()
it->getBeginLoc().getRawEncoding()”
to solve the problem.
For example, for the graph below, I wanted to first get the location encoding of B, assuming it was b, and then when analyzing D, get the base location encoding of D which is also the location encoding of B, d. I originally thought that b==d,so I can identify a relation between B and D, however, this was not the case. So I would like to know if there is any other way that I can establish a relationship with its parent class when I get the cxxRecordDecl of D.
Hi, I would like to use clang-tidy to analyze the inheritance relationship between classes defined in a c++ file. I was going to use
“it=CXXRecordDecl->bases_begin()—CXXRecordDecl->bases_end()
it->getBeginLoc().getRawEncoding()”
to solve the problem.
For example, for the graph below, I wanted to first get the location encoding of B, assuming it was b, and then when analyzing D, get the base location encoding of D which is also the location encoding of B, d. I originally thought that b==d,so I can identify a relation between B and D, however, this was not the case. So I would like to know if there is any other way that I can establish a relationship with its parent class when I get the cxxRecordDecl of D.
You can use it->getType()->getAsCXXRecordDecl() to find a declaration of the base class. Then you can use clang::declaresSameEntity to compare whether that is the same class as B.