Objective C may or may not be enabled when running expressions. There was code that was no allowing "Class" or "id" to be looked up in expressions, but it was preventing these names from being able to be looked up in a namespace or class context. This fixes the issue by passing the namespace_decl along and testing it to make sure we only stop ones at the root namespace level.
For these tiny strings a StringRef == comparison is going to be more efficient than constructing and storing a pointer to a ConstString.
assertEqual(expr_result.GetValue(), None, ...) is better here, because it will print the result of expr_result.GetValue() in the failure case.
LGTM minus some stylistic changes.
There is no need for StringRef as ConstString allows direct comparison against string literals, so this works and is much faster: name == "id" || name == "Class"
Left over from the original test case (TestCallUserAnonTypedef.py)
I don't think we usually check the error, but only if target is valid in any other test. So this whole test can just be this (at least after D77197 has landed):
def test(self): """Test that we can evaluate an expression that finds something inside a namespace that uses an Objective C keyword. """ self.build() target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) self.expect_expr("a::Class x; x", result_type="a::Class")
I think new test files should follow LLVM code style.
I think this review got kind of stuck. I think the only missing thing is simplifying the self.dbg.CreateTarget call in the test, but otherwise this looks good to me. I'm just going to accept this as the bit of cleanup doesn't need another revision.
(Sorry for the delay, I kept clicking on this review and just saw unaddressed comments so I thought this wasn't done yet).