ObjC decl string checks in Expr Eval?

Hey folks,

I'm interested in the following code in ClangASTSource.cpp - ClangASTSource::FindExternalVisibleDecls(), around line 605.

     static ConstString id_name("id");
     static ConstString Class_name("Class");

     if (name == id_name || name == Class_name)

Is this a legacy bit of ObjC early exit magic? I've been wondering why expression evaluation was failing only ever on variables called 'id' :wink: I don't have the ability to validate implications of removal of the code on ObjC. Any opinions on whether this is actually still needed?


I am pretty sure this is the story, though Sean will correct me if I'm wrong... The problem is that id and Class are treated oddly in clang. There are type definitions for them in the ObjC header files (and consequently in debug information), but internally to the compiler those definitions are ignored and they are treated as builtins instead. So you have to not find the type definitions for them and just let clang handle them its own way or it will get all mad at you.


What Jim said was true, but I believe it goes a bit further. If we are asked to lookup "id" or "Class", we will find something in the DWARF which will cause a type to be created which isn't compatible with the internally defined "id" and "Class" that the compiler knows about for Objective C. Then this causes problems evaluating expressions...

What platform are you running your expressions on? We might be able to disable objective C for platforms that don't support it (ObjC should be enabled for anything that is "*-apple-macosx" or "*-apple-ios").


Yeah, I saw there are also checks in SymbolFileDWARF.cpp for "id", "Class" and "SEL" but at least those are behind ObjC language checks.

The platform we're running on doesn't support ObjC. From what I can see these checks in ClangASTSource do no language checking so are applied to everything regardless.


We would be happy to accept a patch that disables these ObjC specific checks if ObjC it isn't enabled for a platform or process.