Instead of hardcoding ClangASTContext and ObjCLanguageRuntime, we can
generalize this by creating the method CalculateCompleteType in
LanguageRuntime and moving the current MaybeCalculateCompleteType
implementation into ObjCLanguageruntime::CalculateCompleteType
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
The main issue I have with this is the name of the function we are adding to LanguageRuntime. See inlined comments.
include/lldb/Target/ObjCLanguageRuntime.h | ||
---|---|---|
253 ↗ | (On Diff #207883) | Is this named correctly? Maybe this should be named "CompilerType GetRuntimeType(CompilerType base_type) override;"? What this function does is gets the real definition from the objective C runtime at the moment. This name would better reflect what is going on and would be something we might ask of a runtime. |
source/Target/ObjCLanguageRuntime.cpp | ||
403 ↗ | (On Diff #207883) | So a main question for ObjC here: do we always want to show the runtime type? Should we not check if the class inside of "base_type" is the one true definition and skip grabbing the runtime type here and return {}? |
404 ↗ | (On Diff #207883) | Remove this variable and just return {} everywhere |
430–433 ↗ | (On Diff #207883) | if (is_pointer_type) return complete_class.GetPointerType(); else return complete_class; |
436 ↗ | (On Diff #207883) | return {}; |
source/Target/ObjCLanguageRuntime.cpp | ||
---|---|---|
403 ↗ | (On Diff #207883) | The only places you can add ivars to an ObjC class are in the @interface declaration (which is usually in the .h file for the class) and in the @implementation and the "class category" - which has to be in the same source file as the @implementation. So if you find debug information for the .m file that contains the @implementation you have seen all the ivars of the class. Clang marks that fact by putting "DW_AT_APPLE_objc_complete_type" with value "true" in the DW_TAG_structure_type die for the class. If you see a type definition so marked, that it the "one true definition". |
Switch to using llvm::Optional<CompilerType> for the return type
Rename method from CalculateCompleteType to GetRuntimeType
source/Target/ObjCLanguageRuntime.cpp | ||
---|---|---|
403 ↗ | (On Diff #207883) | This makes sense to me, but I'm not sure if there are any abstractions that support this today. I did find a method CompilerType::IsCompleteType but I don't think that does this. I think that the only way to accomplish this right now is to reach into the DWARF directly, which I do not want to have to do here. I think preserving existing behavior is okay for now. |