[lldb-dev] [Bug 31704] New: SBModule::FindFirstType does not find a second namespaced typedef with the same name

via lldb-dev lldb-dev at lists.llvm.org
Fri Jan 20 07:25:54 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31704

            Bug ID: 31704
           Summary: SBModule::FindFirstType does not find a second
                    namespaced typedef with the same name
           Product: lldb
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: alexandru.croitor at qt.io
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17871
  --> https://llvm.org/bugs/attachment.cgi?id=17871&action=edit
Example code which shows the issue regarding FindFirstType

SBModule::FindFirstType has an issue with finding namespaced typedefs.
Consider the code:

class Foo {
public:
    typedef bool MyType;
};

class Bar {
public:
    typedef int MyType;
};

int main(int argc, char* argv[]) {
    Foo::MyType foo;
    Bar::MyType bar;
    (void) foo;
    (void) bar;
    return 0;
}

Compile with clang++ -O0 -g ./main.cpp
Run with lldb ./a.out and go into python script mode

>>> lldb.target.FindTypes("MyType").GetSize()
2


>>> print lldb.target.FindFirstType("MyType")
typedef Foo::MyType

>>> print lldb.target.FindFirstType("Foo::MyType")
typedef Foo::MyType

>>> print lldb.target.FindFirstType("Bar::MyType")

As you can see, trying to find Bar::MyType fails, but if I iterate over
FindTypes result, I can find both.

(lldb) version
lldb-360.99.0
  clang revision a41b64721d4be78870711cbb7b5af156a9e1f4ad
  llvm revision 3c45ea423a9e3d27eaf77af0639a73e0c56d9a35

The issue seems to be inside lldb::TypeSP Module::FindFirstType(const
SymbolContext &sc, const ConstString &name, bool exact_match)
which passes "1" as the max_matches argument, and this gets propagated in a
wrong way inside the implementation, where essentially a list of the two types
is found, and the second type is not checked because the first type didn't
match.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20170120/d4d85b37/attachment.html>


More information about the lldb-dev mailing list