Index: packages/Python/lldbsuite/test/expression_command/overloaded_symbol/Makefile =================================================================== --- packages/Python/lldbsuite/test/expression_command/overloaded_symbol/Makefile +++ packages/Python/lldbsuite/test/expression_command/overloaded_symbol/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp overload.cpp + +include $(LEVEL)/Makefile.rules + +overload.o: overload.cpp + $(CXX) -c overload.cpp Index: packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py =================================================================== --- packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py +++ packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py @@ -0,0 +1,36 @@ +""" +Test calling function which has a name conflicting with a .rodata symbol +""" + +from __future__ import print_function + + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +class ExprCommandCallSymbolConfict(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number('main.cpp', '// break here') + + @expectedFlakeyDsym("llvm.org/pr20274") + @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + def test(self): + """Test return value of call to function whose name conflicts with another symbol.""" + self.build() + + # Set breakpoint in main and run exe + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # Function semantics are simply to return the incremented integer parameter + self.expect("expr overloaded_symbol(5)", substrs = ['$0 = 6']) Index: packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp =================================================================== --- packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp +++ packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp @@ -0,0 +1,12 @@ +int return_global(); + +int overloaded_symbol(int x) +{ + return x + 1; +} + +int main() +{ + int my_local = return_global(); // break here + return overloaded_symbol(my_local); +} Index: packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp =================================================================== --- packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp +++ packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp @@ -0,0 +1,6 @@ +const int overloaded_symbol = 2; + +int return_global() +{ + return overloaded_symbol; +} Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1576,7 +1576,7 @@ } while (0); } - if (target && !context.m_found.variable && !namespace_decl) + if (target && !context.m_found.variable && !context.m_found.function && !context.m_found.function_with_type_info && !namespace_decl) { // We couldn't find a non-symbol variable for this. Now we'll hunt for a generic // data symbol, and -- if it is found -- treat it as a variable.