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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp | ||
---|---|---|
582 | For these tiny strings a StringRef == comparison is going to be more efficient than constructing and storing a pointer to a ConstString. | |
lldb/test/API/commands/expression/ignore/TestIgnoreName.py | ||
37 | assertEqual(expr_result.GetValue(), None, ...) is better here, because it will print the result of expr_result.GetValue() in the failure case. | |
39 | same here |
You also mentioned the id case failing as well. We should add that case to the test as well.
LGTM minus some stylistic changes.
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp | ||
---|---|---|
582 | 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" | |
lldb/test/API/commands/expression/ignore/TestIgnoreName.py | ||
7 | Left over from the original test case (TestCallUserAnonTypedef.py) | |
33 | 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") | |
lldb/test/API/commands/expression/ignore/main.cpp | ||
8 | 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).
clang-format-diff not found in user's PATH; not linting file.