Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for ambiguous lookup in expressions between local variable and na…
…mespace Summary: In an Objective-C context a local variable and namespace can cause an ambiguous name lookup when used in an expression. The solution involves mimicking the existing C++ solution which is to add local using declarations for local variables. This causes a different type of lookup to be used which eliminates the namespace during acceptable results filtering. Differential Revision: https://reviews.llvm.org/D59960 llvm-svn: 359921
- Loading branch information
Showing
8 changed files
with
144 additions
and
13 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...Python/lldbsuite/test/expression_command/namespace_local_var_same_name_cpp_and_c/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
LEVEL = ../../make | ||
|
||
CXX_SOURCES := main.cpp | ||
|
||
include $(LEVEL)/Makefile.rules |
24 changes: 24 additions & 0 deletions
24
...n_command/namespace_local_var_same_name_cpp_and_c/TestNamespaceLocalVarSameNameCppAndC.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
class TestNamespaceLocalVarSameNameCppAndC(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
@skipUnlessDarwin | ||
@add_test_categories(["gmodules"]) | ||
def test_namespace_local_var_same_name_cpp_and_c(self): | ||
self.build() | ||
|
||
(self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here', | ||
lldb.SBFileSpec("main.cpp", False)) | ||
|
||
self.expect("expr error", | ||
substrs=['(int) $0 = 1']) | ||
|
||
lldbutil.continue_to_breakpoint(self.process, bkpt) | ||
|
||
self.expect("expr error", | ||
substrs=['(int) $1 = 1']) |
21 changes: 21 additions & 0 deletions
21
...Python/lldbsuite/test/expression_command/namespace_local_var_same_name_cpp_and_c/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace error { | ||
int x; | ||
} | ||
|
||
struct A { | ||
void foo() { | ||
int error=1; | ||
|
||
return; // break here | ||
} | ||
}; | ||
|
||
int main() { | ||
int error=1; | ||
|
||
A a; | ||
|
||
a.foo(); | ||
|
||
return 0; // break here | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/Python/lldbsuite/test/expression_command/namespace_local_var_same_name_obj_c/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
LEVEL = ../../make | ||
OBJCXX_SOURCES := main.mm util.mm | ||
include $(LEVEL)/Makefile.rules | ||
|
||
LDFLAGS += -framework Foundation |
24 changes: 24 additions & 0 deletions
24
...pression_command/namespace_local_var_same_name_obj_c/TestNamespaceLocalVarSameNameObjC.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
class TestNamespaceLocalVarSameNameObjC(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
@skipUnlessDarwin | ||
@add_test_categories(["gmodules"]) | ||
def test_namespace_local_var_same_name_obj_c(self): | ||
self.build() | ||
|
||
(self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here', | ||
lldb.SBFileSpec("util.mm", False)) | ||
|
||
self.expect("expr error", | ||
substrs=['(NSError *) $0 =']) | ||
|
||
lldbutil.continue_to_breakpoint(self.process, bkpt) | ||
|
||
self.expect("expr error", | ||
substrs=['(NSError *) $1 =']) |
16 changes: 16 additions & 0 deletions
16
...ages/Python/lldbsuite/test/expression_command/namespace_local_var_same_name_obj_c/main.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import <Foundation/Foundation.h> | ||
@interface Util : NSObject | ||
+ (void)debugPrintErrorStatic; | ||
- (void)debugPrintError; | ||
@end | ||
|
||
int main(int argc, const char * argv[]) { | ||
[Util debugPrintErrorStatic]; | ||
|
||
Util *u = [[Util alloc] init]; | ||
|
||
[u debugPrintError]; | ||
|
||
return 0; | ||
} | ||
|
22 changes: 22 additions & 0 deletions
22
...ages/Python/lldbsuite/test/expression_command/namespace_local_var_same_name_obj_c/util.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
namespace error { | ||
int blah; | ||
} | ||
|
||
@interface Util : NSObject | ||
+ (void)debugPrintErrorStatic; | ||
- (void)debugPrintError; | ||
@end | ||
|
||
@implementation Util | ||
+ (void)debugPrintErrorStatic { | ||
NSError* error = [NSError errorWithDomain:NSURLErrorDomain code:-1 userInfo:nil]; | ||
NSLog(@"xxx, error = %@", error); // break here | ||
} | ||
|
||
- (void)debugPrintError { | ||
NSError* error = [NSError errorWithDomain:NSURLErrorDomain code:-1 userInfo:nil]; | ||
NSLog(@"xxx, error = %@", error); // break here | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters