[Lldb-commits] [PATCH] D18976: Handle lookup of names identifying both a variable and a type
Ulrich Weigand via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 13 06:51:35 PDT 2016
uweigand updated this revision to Diff 53553.
uweigand added a comment.
Add test case.
http://reviews.llvm.org/D18976
Files:
packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py
packages/Python/lldbsuite/test/lang/cpp/scope/main.cpp
source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -866,8 +866,11 @@
current_id);
}
- if (!context.m_found.variable)
- ClangASTSource::FindExternalVisibleDecls(context);
+ // Always call into ClangASTSource::FindExternalVisibleDecls, even if we already found
+ // some decls above. It might be that Clang is looking for a type, but we have found
+ // a variable of the same name instead. Let ClangASTSource add the type to the result
+ // list as well; Clang will filter out the decl it is actually interested in.
+ ClangASTSource::FindExternalVisibleDecls(context);
}
void
Index: packages/Python/lldbsuite/test/lang/cpp/scope/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/lang/cpp/scope/main.cpp
+++ packages/Python/lldbsuite/test/lang/cpp/scope/main.cpp
@@ -19,6 +19,10 @@
int C::a = 3333;
int a = 4444;
+// Verify that LLDB is able to parse "C::a" even when "C" exists both as a
+// type name and a variable name at the same time.
+int C = 5555;
+
int main() // break here
{
return 0;
Index: packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py
===================================================================
--- packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py
+++ packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py
@@ -54,10 +54,12 @@
'B::a': 2222,
'C::a': 3333,
'::a': 4444,
- 'a': 4444
+ 'a': 4444,
+ '::C': 5555,
+ 'C': 5555
}
- self.assertTrue(global_variables.GetSize() == 4, "target variable returns all variables")
+ self.assertTrue(global_variables.GetSize() == 5, "target variable returns all variables")
for variable in global_variables:
name = variable.GetName()
self.assertTrue(name in global_variables_assert, "target variable returns wrong variable " + name)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18976.53553.patch
Type: text/x-patch
Size: 2237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160413/e24d3429/attachment.bin>
More information about the lldb-commits
mailing list