[Lldb-commits] [lldb] r160466 - in /lldb/trunk: include/lldb/Core/Mangled.h source/Core/Mangled.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Function.cpp source/Symbol/Symbol.cpp source/Symbol/Variable.cpp

Greg Clayton gclayton at apple.com
Wed Jul 18 16:18:10 PDT 2012


Author: gclayton
Date: Wed Jul 18 18:18:10 2012
New Revision: 160466

URL: http://llvm.org/viewvc/llvm-project?rev=160466&view=rev
Log:
Cleaned up the lldb_private::Mangled class to get rid of the tokenizing code that has bit rotted and isn't being used. Also cleaned up the API to the "lldb_private::Mangled" to always take "const ConstString &" arguments instead of both "const ConstString &" and "const char *". 


Modified:
    lldb/trunk/include/lldb/Core/Mangled.h
    lldb/trunk/source/Core/Mangled.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Symbol/Function.cpp
    lldb/trunk/source/Symbol/Symbol.cpp
    lldb/trunk/source/Symbol/Variable.cpp

Modified: lldb/trunk/include/lldb/Core/Mangled.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Mangled.h (original)
+++ lldb/trunk/include/lldb/Core/Mangled.h Wed Jul 18 18:18:10 2012
@@ -33,24 +33,6 @@
 class Mangled
 {
 public:
-
-    //------------------------------------------------------------------
-    /// Token type enumerations.
-    //------------------------------------------------------------------
-    enum TokenType
-    {
-        eInvalid,       ///< Invalid token value (unitialized value)
-        eNameSpace,     ///< The token is a namespace name.
-        eMethodName,    ///< The token is a global or class method name
-        eType,          ///< The token is a language type
-        eTemplate,      ///< The token is a template class
-        eTemplateBeg,   ///< The token that indicates the start of a template parameters
-        eTemplateEnd,   ///< The token that indicates the end of a template parameters
-        eParamsBeg,     ///< The start of a method's parameters (the open parenthesis)
-        eParamsEnd,     ///< The end of a method's parameters (the open parenthesis)
-        eQualifier,     ///< A language qualifier
-        eError          ///< The token failed to parse
-    };
     
     enum NamePreference
     {
@@ -58,224 +40,6 @@
         ePreferDemangled
     };
 
-    //------------------------------------------------------------------
-    /// Mangled::Token structure
-    ///
-    /// As demangled names get tokenized, they get broken up into chunks
-    /// that have type enumerations (TokenType) and string values. Some of
-    /// the tokens are scopes (eTemplateBeg, eTemplateEnd, eParamsBeg,
-    /// eParamsEnd) that can indicate depth and searches can take
-    /// advantage of these to match using wildcards.
-    ///
-    /// For example the mangled string:
-    ///
-    ///     "_ZNSbIhSt11char_traitsIhESaIhEE5eraseEmm"
-    ///
-    /// Demangles to:
-    ///
-    ///     "std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::erase(unsigned long, unsigned long)"
-    ///
-    /// And tokenizes to:
-    ///     @li eNameSpace ("std")
-    ///     @li eTemplate ("basic_string")
-    ///     @li eTemplateBeg ()
-    ///     @li eType ("unsigned char")
-    ///     @li eNameSpace ("std")
-    ///     @li eTemplate ("char_traits")
-    ///     @li eTemplateBeg ()
-    ///     @li eType ("unsigned char")
-    ///     @li eTemplateEnd ()
-    ///     @li eNameSpace ("std")
-    ///     @li eTemplate ("allocator")
-    ///     @li eTemplateBeg ()
-    ///     @li eType ("unsigned char"
-    ///     @li eTemplateEnd ()
-    ///     @li eTemplateEnd ()
-    ///     @li eMethodName ("erase")
-    ///     @li eParamsBeg ()
-    ///     @li eType ("unsigned long")
-    ///     @li eType ("unsigned long")
-    ///     @li eParamsEnd ()
-    ///------------------------------------------------------------------
-    struct Token
-    {
-        //--------------------------------------------------------------
-        /// Default constructor.
-        ///
-        /// Constructs this objet with an invalid token type and an
-        /// empty string.
-        //--------------------------------------------------------------
-        Token();
-
-        //--------------------------------------------------------------
-        /// Equal to operator.
-        ///
-        /// Tests if this object is equal to \a rhs.
-        ///
-        /// @param[in] rhs
-        ///     A const Mangled::Token object reference to compare
-        ///     this object to.
-        ///
-        /// @return
-        ///     \b true if this object is equal to \a rhs, \b false
-        ///     otherwise.
-        //--------------------------------------------------------------
-        bool
-        operator== (const Token& rhs) const;
-
-        //--------------------------------------------------------------
-        /// Dump a description of this object to a Stream \a s.
-        ///
-        /// @param[in] s
-        ///     The stream to which to dump the object descripton.
-        //--------------------------------------------------------------
-        void
-        Dump (Stream *s) const;
-
-        //--------------------------------------------------------------
-        /// Test if this token is a wildcard token.
-        ///
-        /// @return
-        ///     Returns \b true if this token is a wildcard, \b false
-        ///     otherwise.
-        //--------------------------------------------------------------
-        bool
-        IsWildcard() const;
-
-        //--------------------------------------------------------------
-        /// Members
-        //--------------------------------------------------------------
-        TokenType       type;   ///< The type of the token (Mangled::TokenType)
-        ConstString value;  ///< The ConstString value associated with this token
-    };
-
-    //------------------------------------------------------------------
-    /// A collection of tokens.
-    ///
-    /// This class can be instantiated with a demangled names that can
-    /// be used as a query using the
-    /// Mangled::TokenList::MatchesQuery(const TokenList&) const
-    /// function.
-    //------------------------------------------------------------------
-    class TokenList
-    {
-    public:
-        //--------------------------------------------------------------
-        /// Construct with a demangled name.
-        ///
-        /// If demangled is valid the token list will parse up the
-        /// demangled string it is given, else the object will
-        /// initialize an empty token list.
-        //--------------------------------------------------------------
-        TokenList (const char *demangled = NULL);
-
-        //--------------------------------------------------------------
-        /// Destructor
-        //--------------------------------------------------------------
-        ~TokenList ();
-
-        //--------------------------------------------------------------
-        /// Clear the token list.
-        //--------------------------------------------------------------
-        void
-        Clear ();
-
-        //--------------------------------------------------------------
-        /// Dump a description of this object to a Stream \a s.
-        ///
-        /// @param[in] s
-        ///     The stream to which to dump the object descripton.
-        //--------------------------------------------------------------
-        void
-        Dump (Stream *s) const;
-
-        //--------------------------------------------------------------
-        /// Find a token by Mangled::TokenType.
-        ///
-        /// Find the first token in the list that has \a token_type as
-        /// its type.
-        //--------------------------------------------------------------
-        const Token*
-        Find (TokenType token_type) const;
-
-        //--------------------------------------------------------------
-        /// Get a token by index.
-        ///
-        /// @return
-        ///     The token at index \a idx, or NULL if the index is out
-        ///     of range.
-        //--------------------------------------------------------------
-        const Token*
-        GetTokenAtIndex (uint32_t idx) const;
-
-        //--------------------------------------------------------------
-        /// Given a token list, see if it matches this object's tokens.
-        /// \a token_list can contain wild card values to enable powerful
-        /// matching. Matching the std::string::erase(*) example that was
-        /// tokenized above we could use a token list such as:
-        ///
-        ///     token           name
-        ///     -----------     ----------------------------------------
-        ///     eNameSpace      "std"
-        ///     eTemplate       "basic_string"
-        ///     eTemplateBeg
-        ///     eInvalid        "*"
-        ///     eTemplateEnd
-        ///     eMethodName     "erase"
-        ///     eParamsBeg
-        ///     eInvalid        "*"
-        ///     eParamsEnd
-        ///
-        /// @return
-        ///     Returns \b true if it \a token_list matches this
-        ///     object's tokens, \b false otherwise.
-        //--------------------------------------------------------------
-        bool
-        MatchesQuery (const TokenList& token_list) const;
-
-        //--------------------------------------------------------------
-        /// Parses \a demangled into tokens.
-        ///
-        /// This allows complex comparisons to be done on demangled names. Comparisons can
-        /// include wildcards at the namespace, method name, template,
-        /// and template and parameter type levels.
-        ///
-        /// Example queries include:
-        /// "std::basic_string<*>"  // Find all std::basic_string variants
-        /// "std::basic_string<*>::erase(*)"    // Find all std::basic_string::erase variants with any number of parameters
-        /// "*::clear()"            // Find all functions with a method name of
-        ///                         // "clear" that are in any namespace that
-        ///                         // have no parameters
-        /// "::printf"      // Find the printf function in the global namespace
-        /// "printf"        // Ditto
-        /// "foo::*(int)"   // Find all functions in the class or namespace "foo" that take a single integer argument
-        ///
-        /// @return
-        ///     The number of tokens that were decoded, or zero if
-        ///     decoding fails.
-        //--------------------------------------------------------------
-        size_t
-        Parse (const char *demangled);
-
-        //--------------------------------------------------------------
-        /// Get the number of tokens in the list.
-        ///
-        /// @return
-        ///     The number of tokens in the token list.
-        //--------------------------------------------------------------
-        size_t
-        Size () const;
-
-    protected:
-        //--------------------------------------------------------------
-        // Member variables.
-        //--------------------------------------------------------------
-        typedef std::vector<Token> collection; ///< The collection type for a list of Token objects.
-        collection m_tokens; ///< The token list.
-    private:
-        DISALLOW_COPY_AND_ASSIGN (TokenList);
-    };
-
     //----------------------------------------------------------------------
     /// Default constructor.
     ///
@@ -290,22 +54,6 @@
     /// the mangled version.
     ///
     /// @param[in] name
-    ///     The name to copy into this object.
-    ///
-    /// @param[in] is_mangled
-    ///     If \b true then \a name is a mangled name, if \b false then
-    ///     \a name is demangled.
-    //----------------------------------------------------------------------
-    explicit
-    Mangled (const char *name, bool is_mangled);
-
-    //----------------------------------------------------------------------
-    /// Construct with name.
-    ///
-    /// Constructor with an optional string and a boolean indicating if it is
-    /// the mangled version.
-    ///
-    /// @param[in] name
     ///     The already const name to copy into this object.
     ///
     /// @param[in] is_mangled
@@ -325,18 +73,6 @@
     ///     The already const name to copy into this object.
     //----------------------------------------------------------------------
     explicit
-    Mangled (const char *name);
-
-    //----------------------------------------------------------------------
-    /// Construct with name.
-    ///
-    /// Constructor with an optional string and auto-detect if \a name is
-    /// mangled or not.
-    ///
-    /// @param[in] name
-    ///     The already const name to copy into this object.
-    //----------------------------------------------------------------------
-    explicit
     Mangled (const ConstString &name);
 
     //----------------------------------------------------------------------
@@ -441,15 +177,15 @@
     GetDemangledName () const;
 
     void
-    SetDemangledName (const char *name)
+    SetDemangledName (const ConstString &name)
     {
-        m_demangled.SetCString (name);
+        m_demangled = name;
     }
 
     void
-    SetMangledName (const char *name)
+    SetMangledName (const ConstString &name)
     {
-        m_mangled.SetCString (name);
+        m_mangled = name;
     }
 
     //----------------------------------------------------------------------
@@ -511,18 +247,6 @@
     NameMatches (const RegularExpression& regex) const;
 
     //----------------------------------------------------------------------
-    /// Generate the tokens from the demangled name.
-    ///
-    /// @param[out] tokens
-    ///     A token list that will get filled in with the demangled tokens.
-    ///
-    /// @return
-    ///     The number of tokens that were parsed and stored in \a tokens.
-    //----------------------------------------------------------------------
-    size_t
-    GetTokens (Mangled::TokenList &tokens) const;
-
-    //----------------------------------------------------------------------
     /// Get the memory cost of this object.
     ///
     /// Return the size in bytes that this object takes in memory. This
@@ -544,22 +268,6 @@
     /// name, else the demangled name is set to \a name.
     ///
     /// @param[in] name
-    ///     The name to copy into this object.
-    ///
-    /// @param[in] is_mangled
-    ///     If \b true then \a name is a mangled name, if \b false then
-    ///     \a name is demangled.
-    //----------------------------------------------------------------------
-    void
-    SetValue (const char *name, bool is_mangled);
-
-    //----------------------------------------------------------------------
-    /// Set the string value in this object.
-    ///
-    /// If \a is_mangled is \b true, then the mangled named is set to \a
-    /// name, else the demangled name is set to \a name.
-    ///
-    /// @param[in] name
     ///     The already const version of the name for this object.
     ///
     /// @param[in] is_mangled
@@ -591,8 +299,6 @@
 
 
 Stream& operator << (Stream& s, const Mangled& obj);
-Stream& operator << (Stream& s, const Mangled::TokenList& obj);
-Stream& operator << (Stream& s, const Mangled::Token& obj);
 
 } // namespace lldb_private
 

Modified: lldb/trunk/source/Core/Mangled.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Core/Mangled.cpp (original)
+++ lldb/trunk/source/Core/Mangled.cpp Wed Jul 18 18:18:10 2012
@@ -43,20 +43,6 @@
 // Constructor with an optional string and a boolean indicating if it is
 // the mangled version.
 //----------------------------------------------------------------------
-Mangled::Mangled (const char *s, bool mangled) :
-    m_mangled(),
-    m_demangled()
-{
-    if (s && s[0])
-    {
-        SetValue(s, mangled);
-    }
-}
-
-//----------------------------------------------------------------------
-// Constructor with an optional string and a boolean indicating if it is
-// the mangled version.
-//----------------------------------------------------------------------
 Mangled::Mangled (const ConstString &s, bool mangled) :
     m_mangled(),
     m_demangled()
@@ -65,22 +51,10 @@
         SetValue(s, mangled);
 }
 
-//----------------------------------------------------------------------
-// Constructor with an optional string where we try and auto detect if
-// the name is mangled or not by inspecting the string value
-//----------------------------------------------------------------------
-Mangled::Mangled (const char *s) :
+Mangled::Mangled (const ConstString &s) :
     m_mangled(),
     m_demangled()
 {
-    if (s && s[0])
-        SetValue(ConstString(s));
-}
-
-Mangled::Mangled (const ConstString &s) :
-m_mangled(),
-m_demangled()
-{
     if (s)
         SetValue(s);
 }
@@ -147,29 +121,6 @@
 // demangled name is set.
 //----------------------------------------------------------------------
 void
-Mangled::SetValue (const char *s, bool mangled)
-{
-    if (s)
-    {
-        if (mangled)
-        {
-            m_demangled.Clear();        
-            m_mangled.SetCString (s);
-        }
-        else
-        {
-            m_demangled.SetCString(s);
-            m_mangled.Clear();
-        }
-    }
-    else
-    {
-        m_demangled.Clear();        
-        m_mangled.Clear();
-    }
-}
-
-void
 Mangled::SetValue (const ConstString &s, bool mangled)
 {
     if (s)
@@ -298,22 +249,6 @@
 }
 
 //----------------------------------------------------------------------
-// Generate the tokens from the demangled name.
-//
-// Returns the number of tokens that were parsed.
-//----------------------------------------------------------------------
-size_t
-Mangled::GetTokens (Mangled::TokenList &tokens) const
-{
-    tokens.Clear();
-    const ConstString& demangled = GetDemangledName();
-    if (demangled && !demangled.IsEmpty())
-        tokens.Parse(demangled.AsCString());
-
-    return tokens.Size();
-}
-
-//----------------------------------------------------------------------
 // Dump a Mangled object to stream "s". We don't force our
 // demangled name to be computed currently (we don't use the accessor).
 //----------------------------------------------------------------------
@@ -371,459 +306,3 @@
         s << ", demangled = <error>";
     return s;
 }
-
-
-
-
-#pragma mark Mangled::Token
-
-//--------------------------------------------------------------
-// Default constructor
-//--------------------------------------------------------------
-Mangled::Token::Token () :
-    type(eInvalid),
-    value()
-{
-}
-
-//--------------------------------------------------------------
-// Equal to operator
-//--------------------------------------------------------------
-bool
-Mangled::Token::operator== (const Token& rhs) const
-{
-    return type == rhs.type && value == rhs.value;
-}
-
-//--------------------------------------------------------------
-// Dump the token to a stream "s"
-//--------------------------------------------------------------
-void
-Mangled::Token::Dump (Stream *s) const
-{
-    switch (type)
-    {
-    case eInvalid:      s->PutCString("invalid    "); break;
-    case eNameSpace:    s->PutCString("namespace  "); break;
-    case eMethodName:   s->PutCString("method     "); break;
-    case eType:         s->PutCString("type       "); break;
-    case eTemplate:     s->PutCString("template   "); break;
-    case eTemplateBeg:  s->PutCString("template < "); break;
-    case eTemplateEnd:  s->PutCString("template > "); break;
-    case eParamsBeg:    s->PutCString("params   ( "); break;
-    case eParamsEnd:    s->PutCString("params   ) "); break;
-    case eQualifier:    s->PutCString("qualifier  "); break;
-    case eError:        s->PutCString("ERROR      "); break;
-    default:
-        s->Printf("type = %i", type);
-        break;
-    }
-    value.DumpDebug(s);
-}
-
-//--------------------------------------------------------------
-// Returns true if this token is a wildcard
-//--------------------------------------------------------------
-bool
-Mangled::Token::IsWildcard () const
-{
-    static ConstString g_wildcard_str("*");
-    return value == g_wildcard_str;
-}
-
-
-//----------------------------------------------------------------------
-// Dump "obj" to the supplied stream "s"
-//----------------------------------------------------------------------
-Stream&
-lldb_private::operator << (Stream& s, const Mangled::Token& obj)
-{
-    obj.Dump(&s);
-    return s;
-}
-
-
-#pragma mark Mangled::TokenList
-//----------------------------------------------------------------------
-// Mangled::TokenList
-//----------------------------------------------------------------------
-
-//--------------------------------------------------------------
-// Default constructor. If demangled is non-NULL and not-empty
-// the token list will parse up the demangled string it is
-// given, else the object will initialize an empty token list.
-//--------------------------------------------------------------
-Mangled::TokenList::TokenList (const char *demangled) :
-    m_tokens()
-{
-    if (demangled && demangled[0])
-    {
-        Parse(demangled);
-    }
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-Mangled::TokenList::~TokenList ()
-{
-}
-
-//----------------------------------------------------------------------
-// Parses "demangled" into tokens. This allows complex
-// comparisons to be done. Comparisons can include wildcards at
-// the namespace, method name, template, and template and
-// parameter type levels.
-//
-// Example queries include:
-// "std::basic_string<*>"   // Find all std::basic_string variants
-// "std::basic_string<*>::erase(*)" // Find all std::basic_string::erase variants with any number of parameters
-// "*::clear()"             // Find all functions with a method name of
-//                          // "clear" that are in any namespace that
-//                          // have no parameters
-// "::printf"               // Find the printf function in the global namespace
-// "printf"                 // Ditto
-// "foo::*(int)"            // Find all functions in the class or namespace "foo" that take a single integer argument
-//
-// Returns the number of tokens that were decoded, or zero when
-// we fail.
-//----------------------------------------------------------------------
-size_t
-Mangled::TokenList::Parse (const char *s)
-{
-    m_tokens.clear();
-
-    Token token;
-    token.type = eNameSpace;
-
-    TokenType max_type = eInvalid;
-    const char *p = s;
-    size_t span = 0;
-    size_t sep_size = 0;
-
-    while (*p != '\0')
-    {
-        p = p + span + sep_size;
-        while (isspace(*p))
-            ++p;
-
-        if (*p == '\0')
-            break;
-
-        span = strcspn(p, ":<>(),");
-        sep_size = 1;
-        token.type = eInvalid;
-        switch (p[span])
-        {
-        case '\0':
-            break;
-
-        case ':':
-            if (p[span+1] == ':')
-            {
-                sep_size = 2;
-                if (span > 0)
-                {
-                    token.type = eNameSpace;
-                    token.value.SetCStringWithLength (p, span);
-                    m_tokens.push_back(token);
-                }
-                else
-                    continue;
-            }
-            break;
-
-        case '(':
-            if (span > 0)
-            {
-                token.type = eMethodName;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eParamsBeg;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-
-        case ',':
-            if (span > 0)
-            {
-                token.type = eType;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-            else
-            {
-                continue;
-            }
-            break;
-
-        case ')':
-            if (span > 0)
-            {
-                token.type = eType;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eParamsEnd;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-
-        case '<':
-            if (span > 0)
-            {
-                token.type = eTemplate;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eTemplateBeg;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-
-        case '>':
-            if (span > 0)
-            {
-                token.type = eType;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eTemplateEnd;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-        }
-
-        if (max_type < token.type)
-            max_type = token.type;
-
-        if (token.type == eInvalid)
-        {
-            if (max_type >= eParamsEnd)
-            {
-                token.type = eQualifier;
-                token.value.SetCString(p);
-                m_tokens.push_back(token);
-            }
-            else if (max_type >= eParamsBeg)
-            {
-                token.type = eType;
-                token.value.SetCString(p);
-                m_tokens.push_back(token);
-            }
-            else
-            {
-                token.type = eMethodName;
-                token.value.SetCString(p);
-                m_tokens.push_back(token);
-            }
-            break;
-        }
-    }
-    return m_tokens.size();
-}
-
-
-//----------------------------------------------------------------------
-// Clear the token list.
-//----------------------------------------------------------------------
-void
-Mangled::TokenList::Clear ()
-{
-    m_tokens.clear();
-}
-
-//----------------------------------------------------------------------
-// Dump the token list to the stream "s"
-//----------------------------------------------------------------------
-void
-Mangled::TokenList::Dump (Stream *s) const
-{
-    collection::const_iterator pos;
-    collection::const_iterator beg = m_tokens.begin();
-    collection::const_iterator end = m_tokens.end();
-    for (pos = beg; pos != end; ++pos)
-    {
-        s->Indent("token[");
-        *s << (uint32_t)std::distance(beg, pos) << "] = " << *pos << "\n";
-    }
-}
-
-//----------------------------------------------------------------------
-// Find the first token in the list that has "token_type" as its
-// type
-//----------------------------------------------------------------------
-const Mangled::Token *
-Mangled::TokenList::Find (TokenType token_type) const
-{
-    collection::const_iterator pos;
-    collection::const_iterator beg = m_tokens.begin();
-    collection::const_iterator end = m_tokens.end();
-    for (pos = beg; pos != end; ++pos)
-    {
-        if (pos->type == token_type)
-            return &(*pos);
-    }
-    return NULL;
-}
-
-//----------------------------------------------------------------------
-// Return the token at index "idx", or NULL if the index is
-// out of range.
-//----------------------------------------------------------------------
-const Mangled::Token *
-Mangled::TokenList::GetTokenAtIndex (uint32_t idx) const
-{
-    if (idx < m_tokens.size())
-        return &m_tokens[idx];
-    return NULL;
-}
-
-
-//----------------------------------------------------------------------
-// Given a token list, see if it matches this object's tokens.
-// "token_list" can contain wild card values to enable powerful
-// matching. Matching the std::string::erase(*) example that was
-// tokenized above we could use a token list such as:
-//
-//      token           name
-//      -----------     ----------------------------------------
-//      eNameSpace      "std"
-//      eTemplate       "basic_string"
-//      eTemplateBeg
-//      eInvalid        "*"
-//      eTemplateEnd
-//      eMethodName     "erase"
-//      eParamsBeg
-//      eInvalid        "*"
-//      eParamsEnd
-//
-// Returns true if it "token_list" matches this object's tokens,
-// false otherwise.
-//----------------------------------------------------------------------
-bool
-Mangled::TokenList::MatchesQuery (const Mangled::TokenList &match) const
-{
-    size_t match_count = 0;
-    collection::const_iterator pos;
-    collection::const_iterator pos_end = m_tokens.end();
-
-    collection::const_iterator match_pos;
-    collection::const_iterator match_pos_end = match.m_tokens.end();
-    collection::const_iterator match_wildcard_pos = match_pos_end;
-    collection::const_iterator match_next_pos = match_pos_end;
-
-    size_t template_scope_depth = 0;
-
-    for (pos = m_tokens.begin(), match_pos = match.m_tokens.begin();
-         pos != pos_end && match_pos != match_pos_end;
-         ++match_pos)
-    {
-        match_next_pos = match_pos + 1;
-        // Is this a wildcard?
-        if (match_pos->IsWildcard())
-        {
-            if (match_wildcard_pos != match_pos_end)
-                return false;   // Can't have two wildcards in effect at once.
-
-            match_wildcard_pos = match_pos;
-            // Are we at the end of the MATCH token list?
-            if (match_next_pos == match_pos_end)
-            {
-                // There is nothing more to match, return if we have any matches so far...
-                return match_count > 0;
-            }
-        }
-
-        if (match_pos->type == eInvalid || match_pos->type == eError)
-        {
-            return false;
-        }
-        else
-        {
-            if (match_pos->type == eTemplateBeg)
-            {
-                ++template_scope_depth;
-            }
-            else if (match_pos->type == eTemplateEnd)
-            {
-                assert(template_scope_depth > 0);
-                --template_scope_depth;
-            }
-
-            // Do we have a wildcard going right now?
-            if (match_wildcard_pos == match_pos_end)
-            {
-                // No wildcard matching right now, just check and see if things match
-                if (*pos == *match_pos)
-                    ++match_count;
-                else
-                    return false;
-            }
-            else
-            {
-                // We have a wildcard match going
-
-                // For template types we need to make sure to match the template depths...
-                const size_t start_wildcard_template_scope_depth = template_scope_depth;
-                size_t curr_wildcard_template_scope_depth = template_scope_depth;
-                while (pos != pos_end)
-                {
-                    if (match_wildcard_pos->type == eNameSpace && pos->type == eParamsBeg)
-                        return false;
-
-                    if (start_wildcard_template_scope_depth == curr_wildcard_template_scope_depth)
-                    {
-                        if (*pos == *match_next_pos)
-                        {
-                            ++match_count;
-                            match_pos = match_next_pos;
-                            match_wildcard_pos = match_pos_end;
-                            break;
-                        }
-                    }
-                    if (pos->type == eTemplateBeg)
-                        ++curr_wildcard_template_scope_depth;
-                    else if (pos->type == eTemplateEnd)
-                        --curr_wildcard_template_scope_depth;
-
-
-                    ++pos;
-                }
-            }
-        }
-
-        if (pos != pos_end)
-            ++pos;
-    }
-    if (match_pos != match_pos_end)
-        return false;
-
-    return match_count > 0;
-}
-
-
-//----------------------------------------------------------------------
-// Return the number of tokens in the token collection
-//----------------------------------------------------------------------
-size_t
-Mangled::TokenList::Size () const
-{
-    return m_tokens.size();
-}
-
-
-//----------------------------------------------------------------------
-// Stream out the tokens
-//----------------------------------------------------------------------
-Stream&
-lldb_private::operator << (Stream& s, const Mangled::TokenList& obj)
-{
-    obj.Dump(&s);
-    return s;
-}

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Jul 18 18:18:10 2012
@@ -2520,7 +2520,7 @@
                             {
                                 // We have two consecutive N_SO entries where the first contains a directory
                                 // and the second contains a full path.
-                                sym[sym_idx - 1].GetMangled().SetValue(symbol_name, false);
+                                sym[sym_idx - 1].GetMangled().SetValue(ConstString(symbol_name), false);
                                 m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1;
                                 add_nlist = false;
                             }
@@ -2542,7 +2542,7 @@
                                 if (*full_so_path.rbegin() != '/')
                                     full_so_path += '/';
                                 full_so_path += symbol_name;
-                                sym[sym_idx - 1].GetMangled().SetValue(full_so_path.c_str(), false);
+                                sym[sym_idx - 1].GetMangled().SetValue(ConstString(full_so_path.c_str()), false);
                                 add_nlist = false;
                                 m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1;
                             }
@@ -2846,8 +2846,8 @@
 
                 if (symbol_name_non_abi_mangled)
                 {
-                    sym[sym_idx].GetMangled().SetMangledName (symbol_name_non_abi_mangled);
-                    sym[sym_idx].GetMangled().SetDemangledName (symbol_name);
+                    sym[sym_idx].GetMangled().SetMangledName (ConstString(symbol_name_non_abi_mangled));
+                    sym[sym_idx].GetMangled().SetDemangledName (ConstString(symbol_name));
                 }
                 else
                 {
@@ -2859,7 +2859,7 @@
 
                     if (symbol_name)
                     {
-                        sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled);
+                        sym[sym_idx].GetMangled().SetValue(ConstString(symbol_name), symbol_name_is_mangled);
                     }
                 }
 
@@ -3065,7 +3065,7 @@
                                           ++synthetic_function_symbol_idx,
                                           module_sp->GetFileSpec().GetFilename().GetCString());
                                 sym[sym_idx].SetID (synthetic_sym_id++);
-                                sym[sym_idx].GetMangled().SetDemangledName(synthetic_function_symbol);
+                                sym[sym_idx].GetMangled().SetDemangledName(ConstString(synthetic_function_symbol));
                                 sym[sym_idx].SetType (eSymbolTypeCode);
                                 sym[sym_idx].SetIsSynthetic (true);
                                 sym[sym_idx].GetAddress() = symbol_addr;

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Wed Jul 18 18:18:10 2012
@@ -544,7 +544,7 @@
                     symbol.storage  = symtab_data.GetU8  (&offset);
                     symbol.naux     = symtab_data.GetU8  (&offset);		
                     Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
-                    symbols[i].GetMangled ().SetValue (symbol_name.c_str(), symbol_name[0]=='_' && symbol_name[1] == 'Z');
+                    symbols[i].GetMangled ().SetValue (ConstString(symbol_name.c_str()));
                     symbols[i].GetAddress() = symbol_addr;
 
                     if (symbol.naux > 0)

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Jul 18 18:18:10 2012
@@ -797,7 +797,7 @@
                     // with duplicate entries
                     if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (name && ::strcmp(name, mangled_cstr) != 0)))
                     {
-                        Mangled mangled (mangled_cstr, true);
+                        Mangled mangled (ConstString(mangled_cstr), true);
                         func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
                         if (mangled.GetDemangledName())
                             func_fullnames.Insert (mangled.GetDemangledName(), die.GetOffset());
@@ -819,7 +819,7 @@
                     // with duplicate entries
                     if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
                     {
-                        Mangled mangled (mangled_cstr, true);
+                        Mangled mangled (ConstString(mangled_cstr), true);
                         func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
                         if (mangled.GetDemangledName())
                             func_fullnames.Insert (mangled.GetDemangledName(), die.GetOffset());
@@ -864,7 +864,7 @@
                 // with duplicate entries
                 if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
                 {
-                    Mangled mangled (mangled_cstr, true);
+                    Mangled mangled (ConstString(mangled_cstr), true);
                     globals.Insert (mangled.GetMangledName(), die.GetOffset());
                     if (mangled.GetDemangledName())
                         globals.Insert (mangled.GetDemangledName(), die.GetOffset());

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Jul 18 18:18:10 2012
@@ -859,9 +859,9 @@
         {
             Mangled func_name;
             if (mangled)
-                func_name.SetValue(mangled, true);
+                func_name.SetValue(ConstString(mangled), true);
             else if (name)
-                func_name.SetValue(name, false);
+                func_name.SetValue(ConstString(name), false);
 
             FunctionSP func_sp;
             std::auto_ptr<Declaration> decl_ap;
@@ -3069,7 +3069,7 @@
             if (attributes.ExtractFormValueAtIndex(this, idx, form_value))
             {
                 const char *name = form_value.AsCString(&get_debug_str_data());
-                best_name.SetValue (name, true);
+                best_name.SetValue (ConstString(name), true);
             } 
         }
         if (best_name)

Modified: lldb/trunk/source/Symbol/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Function.cpp (original)
+++ lldb/trunk/source/Symbol/Function.cpp Wed Jul 18 18:18:10 2012
@@ -100,7 +100,7 @@
     const Declaration *call_decl_ptr
 ) :
     FunctionInfo(name, decl_ptr),
-    m_mangled(mangled, true),
+    m_mangled(ConstString(mangled), true),
     m_call_decl (call_decl_ptr)
 {
 }
@@ -233,7 +233,7 @@
     m_comp_unit (comp_unit),
     m_type_uid (type_uid),
     m_type (type),
-    m_mangled (mangled, true),
+    m_mangled (ConstString(mangled), true),
     m_block (func_uid),
     m_range (range),
     m_frame_base (),

Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Wed Jul 18 18:18:10 2012
@@ -54,7 +54,7 @@
 ) :
     SymbolContextScope (),
     m_uid (symID),
-    m_mangled (name, name_is_mangled),
+    m_mangled (ConstString(name), name_is_mangled),
     m_type_data (0),
     m_type_data_resolved (false),
     m_is_synthetic (is_artificial),
@@ -84,7 +84,7 @@
 ) :
     SymbolContextScope (),
     m_uid (symID),
-    m_mangled (name, name_is_mangled),
+    m_mangled (ConstString(name), name_is_mangled),
     m_type_data (0),
     m_type_data_resolved (false),
     m_is_synthetic (is_artificial),

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=160466&r1=160465&r2=160466&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Wed Jul 18 18:18:10 2012
@@ -46,7 +46,7 @@
 ) :
     UserID(uid),
     m_name(name),
-    m_mangled (mangled, true),
+    m_mangled (ConstString(mangled), true),
     m_symfile_type_sp(symfile_type_sp),
     m_scope(scope),
     m_owner_scope(context),





More information about the lldb-commits mailing list