diff options
author | Greg Clayton <gclayton@apple.com> | 2012-07-18 23:18:10 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-07-18 23:18:10 +0000 |
commit | 037520e9cf8d2293ce2abfd5d4cde583e79556a6 (patch) | |
tree | db91a4c957aff985f8d4c870ab482e51a7bb77f1 | |
parent | 9208abd7c330510238568b0ccb4313e2f90029ac (diff) | |
download | bcm5719-llvm-037520e9cf8d2293ce2abfd5d4cde583e79556a6.tar.gz bcm5719-llvm-037520e9cf8d2293ce2abfd5d4cde583e79556a6.zip |
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 *".
llvm-svn: 160466
-rw-r--r-- | lldb/include/lldb/Core/Mangled.h | 302 | ||||
-rw-r--r-- | lldb/source/Core/Mangled.cpp | 523 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Symbol/Function.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Symbol/Symbol.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Symbol/Variable.cpp | 2 |
9 files changed, 23 insertions, 838 deletions
diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 3bbe4c338ca..8732dc00270 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -33,24 +33,6 @@ namespace lldb_private { 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 @@ public: 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 @@ public: /// 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 @@ public: /// 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 @@ public: 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 @@ public: 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 @@ public: /// 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 @@ private: 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 diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 73e45d65507..200f8ba6f9a 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -43,20 +43,6 @@ Mangled::Mangled () : // 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 @@ Mangled::Mangled (const ConstString &s, bool mangled) : 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 @@ Mangled::Compare (const Mangled& a, const Mangled& b) // 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 @@ Mangled::GetName (Mangled::NamePreference preference) const } //---------------------------------------------------------------------- -// 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 @@ operator << (Stream& s, const Mangled& obj) 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; -} diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 7d44f8316e6..8b074ce24bd 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -2520,7 +2520,7 @@ struct lldb_copy_dyld_cache_local_symbols_entry { // 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 @@ struct lldb_copy_dyld_cache_local_symbols_entry 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 @@ struct lldb_copy_dyld_cache_local_symbols_entry 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 @@ struct lldb_copy_dyld_cache_local_symbols_entry 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 @@ struct lldb_copy_dyld_cache_local_symbols_entry ++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; diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index cc37568d6a0..36480d57d8c 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -544,7 +544,7 @@ ObjectFilePECOFF::GetSymtab() 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) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index b0ec6091f8b..60f349c4005 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -797,7 +797,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, // 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 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, // 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 @@ DWARFCompileUnit::Index (const uint32_t cu_idx, // 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()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 20443244dec..8882c9187bc 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -859,9 +859,9 @@ SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, DWARFCompile { 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 @@ SymbolFileDWARF::FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die, 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) diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 7fa6c6f4379..9ee35e3737e 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -100,7 +100,7 @@ InlineFunctionInfo::InlineFunctionInfo 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 @@ Function::Function 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 (), diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index ddbf63554ed..7cf3da77952 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -54,7 +54,7 @@ Symbol::Symbol ) : 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 @@ Symbol::Symbol ) : 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), diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 616eaa7e809..df008737e6d 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -46,7 +46,7 @@ Variable::Variable ) : 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), |