clang::RecordDecl is Clang's type for describing structs when parsing C while clang::CXXRecordDecl
is a subclass of RecordDecl that represents structs/classes when parsing C++. Any code that isn't
exclusive to C++ should use RecordDecl when doing RTTI checks on declarations to be compatible
to both C and C++. For example, when iterating over fields of a record, RecordDecl is the right type
while for iterating over base classes, CXXRecordDecl is the right type.
However, as we currently only create CXXRecordDecl in LLDB at the moment (caused by all parsers
being set to C++ mode), a few of checks slipped into the code base where we incorrectly check for
CXXRecordDecl even when doing logic that also applies to C. This causes that if we ever allow C ASTs in
LLDB's type system, these check will start failing.
This patch just moves the` CXXRecordDecl` casts I found to be too strict to RecordDecl. The patch is
NFC at the moment as we only have C++ types as described above, but it makes the code base less hostile
for types from a Clang instance that parses C.
I am wondering if this was a bug since anonymous classes is only an extension in C++ but it is a normative part of C.
So were we not correctly annotating C anonymous structs? If so we should have a test for that.
If we were correctly labeling C anonymous structs, I wonder were we got that right?
see D66175 for more context.