[Lldb-commits] [lldb] r238459 - Move inlined cxa_demangle.cpp to a separate file.

Zachary Turner zturner at google.com
Thu May 28 12:58:46 PDT 2015


Ahh, no worries if a patch has already been submitted.  Thanks

On Thu, May 28, 2015 at 12:54 PM, Chaoren Lin <chaorenl at google.com> wrote:

> I commit this (http://reviews.llvm.org/D9949) and
> http://reviews.llvm.org/D10040 together. This one was sort of expected to
> break on Windows because of the missing keywords in MSVC, but I wanted to
> preserve the original cxa_demangle.cpp in history somewhere. The immediate
> next commit should fix it. I had assumed that the buildbot would test both
> together since I committed them together, but apparently I'm wrong. I
> apologize.
>
> On Thu, May 28, 2015 at 12:40 PM, Zachary Turner <zturner at google.com>
> wrote:
>
>> Can you take a look at this build failure?
>> http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc/builds/6224/steps/build/logs/stdio
>>
>> On Thu, May 28, 2015 at 12:33 PM Chaoren Lin <chaorenl at google.com> wrote:
>>
>>> Author: chaoren
>>> Date: Thu May 28 14:15:15 2015
>>> New Revision: 238459
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=238459&view=rev
>>> Log:
>>> Move inlined cxa_demangle.cpp to a separate file.
>>>
>>> Summary: In preparation for some changes to make this compatible with
>>> MSVC.
>>>
>>> Reviewers: emaste, zturner, clayborg
>>>
>>> Reviewed By: clayborg
>>>
>>> Subscribers: lldb-commits
>>>
>>> Differential Revision: http://reviews.llvm.org/D9949
>>>
>>> Added:
>>>     lldb/trunk/include/lldb/Core/CxaDemangle.h
>>>     lldb/trunk/include/lldb/Core/FastDemangle.h
>>>     lldb/trunk/source/Core/CxaDemangle.cpp
>>>       - copied, changed from r238454, lldb/trunk/source/Core/Mangled.cpp
>>> Modified:
>>>     lldb/trunk/source/Core/CMakeLists.txt
>>>     lldb/trunk/source/Core/Mangled.cpp
>>>
>>> Added: lldb/trunk/include/lldb/Core/CxaDemangle.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/CxaDemangle.h?rev=238459&view=auto
>>>
>>> ==============================================================================
>>> --- lldb/trunk/include/lldb/Core/CxaDemangle.h (added)
>>> +++ lldb/trunk/include/lldb/Core/CxaDemangle.h Thu May 28 14:15:15 2015
>>> @@ -0,0 +1,21 @@
>>> +//===-- CxaDemangle.h -------------------------------------------*- C++
>>> -*-===//
>>> +//
>>> +//                     The LLVM Compiler Infrastructure
>>> +//
>>> +// This file is distributed under the University of Illinois Open Source
>>> +// License. See LICENSE.TXT for details.
>>> +//
>>>
>>> +//===----------------------------------------------------------------------===//
>>> +
>>> +#ifndef liblldb_CxaDemangle_h_
>>> +#define liblldb_CxaDemangle_h_
>>> +
>>> +namespace lldb_private
>>> +{
>>> +
>>> +    char*
>>> +    __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int*
>>> status);
>>> +
>>> +}
>>> +
>>> +#endif
>>>
>>> Added: lldb/trunk/include/lldb/Core/FastDemangle.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FastDemangle.h?rev=238459&view=auto
>>>
>>> ==============================================================================
>>> --- lldb/trunk/include/lldb/Core/FastDemangle.h (added)
>>> +++ lldb/trunk/include/lldb/Core/FastDemangle.h Thu May 28 14:15:15 2015
>>> @@ -0,0 +1,24 @@
>>> +//===-- FastDemangle.h ------------------------------------------*- C++
>>> -*-===//
>>> +//
>>> +//                     The LLVM Compiler Infrastructure
>>> +//
>>> +// This file is distributed under the University of Illinois Open Source
>>> +// License. See LICENSE.TXT for details.
>>> +//
>>>
>>> +//===----------------------------------------------------------------------===//
>>> +
>>> +#ifndef liblldb_FastDemangle_h_
>>> +#define liblldb_FastDemangle_h_
>>> +
>>> +namespace lldb_private
>>> +{
>>> +
>>> +    char *
>>> +    FastDemangle(const char *mangled_name);
>>> +
>>> +    char *
>>> +    FastDemangle(const char *mangled_name, long mangled_name_length);
>>> +
>>> +}
>>> +
>>> +#endif
>>>
>>> Modified: lldb/trunk/source/Core/CMakeLists.txt
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CMakeLists.txt?rev=238459&r1=238458&r2=238459&view=diff
>>>
>>> ==============================================================================
>>> --- lldb/trunk/source/Core/CMakeLists.txt (original)
>>> +++ lldb/trunk/source/Core/CMakeLists.txt Thu May 28 14:15:15 2015
>>> @@ -14,6 +14,7 @@ add_lldb_library(lldbCore
>>>    ConnectionMachPort.cpp
>>>    ConnectionSharedMemory.cpp
>>>    ConstString.cpp
>>> +  CxaDemangle.cpp
>>>    DataBufferHeap.cpp
>>>    DataBufferMemoryMap.cpp
>>>    DataEncoder.cpp
>>>
>>> Copied: lldb/trunk/source/Core/CxaDemangle.cpp (from r238454,
>>> lldb/trunk/source/Core/Mangled.cpp)
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CxaDemangle.cpp?p2=lldb/trunk/source/Core/CxaDemangle.cpp&p1=lldb/trunk/source/Core/Mangled.cpp&r1=238454&r2=238459&rev=238459&view=diff
>>>
>>> ==============================================================================
>>> --- lldb/trunk/source/Core/Mangled.cpp (original)
>>> +++ lldb/trunk/source/Core/CxaDemangle.cpp Thu May 28 14:15:15 2015
>>> @@ -1,45 +1,12 @@
>>> -//===-- Mangled.cpp ---------------------------------------------*- C++
>>> -*-===//
>>> -//
>>> -//                     The LLVM Compiler Infrastructure
>>> -//
>>> -// This file is distributed under the University of Illinois Open Source
>>> -// License. See LICENSE.TXT for details.
>>> -//
>>>
>>> -//===----------------------------------------------------------------------===//
>>> -
>>> -
>>> -// FreeBSD9-STABLE requires this to know about size_t in cxxabi.h
>>> -#include <cstddef>
>>> -#if defined(_MSC_VER)
>>> -#include "lldb/Host/windows/windows.h"
>>> -#include <Dbghelp.h>
>>> -#elif defined (__FreeBSD__)
>>> -#define LLDB_USE_BUILTIN_DEMANGLER
>>> -#else
>>> -#include <cxxabi.h>
>>> -#endif
>>> -
>>> -#ifdef LLDB_USE_BUILTIN_DEMANGLER
>>> -
>>> -// Provide a fast-path demangler implemented in FastDemangle.cpp until
>>> it can
>>> -// replace the existing C++ demangler with a complete implementation
>>> -namespace lldb_private
>>> -{
>>> -    extern char * FastDemangle (const char * mangled_name,
>>> -                                long mangled_name_length);
>>> -}
>>> -
>>>  //----------------------------------------------------------------------
>>>  // Inlined copy of:
>>>  //
>>> http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp
>>> -// revision 199944.
>>> +// revision 238263.
>>>  //
>>>  // Changes include:
>>> -// - remove the "__cxxabiv1" namespace
>>> -// - stripped GCC attributes()
>>> -// - removed extern "C" from the cxa_demangle function
>>> -// - Changed the scope of the unnamed namespace to include cxa_demangle
>>> -//   function.
>>> +// - Renamed the "__cxxabiv1" namespace to "lldb_private"
>>> +// - Stripped GCC attributes()
>>> +// - Removed extern "C" from the cxa_demangle function
>>>  // - Added "#undef _LIBCPP_EXTERN_TEMPLATE" to avoid warning
>>>  //----------------------------------------------------------------------
>>>
>>> @@ -65,6 +32,8 @@ namespace lldb_private
>>>  #include <cstring>
>>>  #include <cctype>
>>>
>>> +namespace lldb_private
>>> +{
>>>
>>>  namespace
>>>  {
>>> @@ -83,7 +52,8 @@ template <class C>
>>>  template <class C>
>>>      const char* parse_encoding(const char* first, const char* last, C&
>>> db);
>>>  template <class C>
>>> -    const char* parse_name(const char* first, const char* last, C& db);
>>> +    const char* parse_name(const char* first, const char* last, C& db,
>>> +                           bool* ends_with_template_args = 0);
>>>  template <class C>
>>>      const char* parse_expression(const char* first, const char* last,
>>> C& db);
>>>  template <class C>
>>> @@ -99,51 +69,51 @@ template <class C>
>>>  void
>>>  print_stack(const C& db)
>>>  {
>>> -    printf("---------\n");
>>> -    printf("names:\n");
>>> +    fprintf(stderr, "---------\n");
>>> +    fprintf(stderr, "names:\n");
>>>      for (auto& s : db.names)
>>> -        printf("{%s#%s}\n", s.first.c_str(), s.second.c_str());
>>> +        fprintf(stderr, "{%s#%s}\n", s.first.c_str(), s.second.c_str());
>>>      int i = -1;
>>> -    printf("subs:\n");
>>> +    fprintf(stderr, "subs:\n");
>>>      for (auto& v : db.subs)
>>>      {
>>>          if (i >= 0)
>>> -            printf("S%i_ = {", i);
>>> +            fprintf(stderr, "S%i_ = {", i);
>>>          else
>>> -            printf("S_  = {");
>>> +            fprintf(stderr, "S_  = {");
>>>          for (auto& s : v)
>>> -            printf("{%s#%s}", s.first.c_str(), s.second.c_str());
>>> -        printf("}\n");
>>> +            fprintf(stderr, "{%s#%s}", s.first.c_str(),
>>> s.second.c_str());
>>> +        fprintf(stderr, "}\n");
>>>          ++i;
>>>      }
>>> -    printf("template_param:\n");
>>> +    fprintf(stderr, "template_param:\n");
>>>      for (auto& t : db.template_param)
>>>      {
>>> -        printf("--\n");
>>> +        fprintf(stderr, "--\n");
>>>          i = -1;
>>>          for (auto& v : t)
>>>          {
>>>              if (i >= 0)
>>> -                printf("T%i_ = {", i);
>>> +                fprintf(stderr, "T%i_ = {", i);
>>>              else
>>> -                printf("T_  = {");
>>> +                fprintf(stderr, "T_  = {");
>>>              for (auto& s : v)
>>> -                printf("{%s#%s}", s.first.c_str(), s.second.c_str());
>>> -            printf("}\n");
>>> +                fprintf(stderr, "{%s#%s}", s.first.c_str(),
>>> s.second.c_str());
>>> +            fprintf(stderr, "}\n");
>>>              ++i;
>>>          }
>>>      }
>>> -    printf("---------\n\n");
>>> +    fprintf(stderr, "---------\n\n");
>>>  }
>>>
>>>  template <class C>
>>>  void
>>>  print_state(const char* msg, const char* first, const char* last, const
>>> C& db)
>>>  {
>>> -    printf("%s: ", msg);
>>> +    fprintf(stderr, "%s: ", msg);
>>>      for (; first != last; ++first)
>>> -        printf("%c", *first);
>>> -    printf("\n");
>>> +        fprintf(stderr, "%c", *first);
>>> +    fprintf(stderr, "\n");
>>>      print_stack(db);
>>>  }
>>>
>>> @@ -200,7 +170,11 @@ constexpr const char* float_data<double>
>>>  template <>
>>>  struct float_data<long double>
>>>  {
>>> +#if defined(__arm__)
>>> +    static const size_t mangled_size = 16;
>>> +#else
>>>      static const size_t mangled_size = 20;  // May need to be adjusted
>>> to 16 or 24 on other platforms
>>> +#endif
>>>      static const size_t max_demangled_size = 40;
>>>      static constexpr const char* spec = "%LaL";
>>>  };
>>> @@ -235,7 +209,7 @@ parse_floating_number(const char* first,
>>>          }
>>>          if (*t == 'E')
>>>          {
>>> -#if __LITTLE_ENDIAN__
>>> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
>>>              std::reverse(buf, e);
>>>  #endif
>>>              char num[float_data<Float>::max_demangled_size] = {0};
>>> @@ -397,6 +371,7 @@ parse_substitution(const char* first, co
>>>  //                ::= Di   # char32_t
>>>  //                ::= Ds   # char16_t
>>>  //                ::= Da   # auto (in dependent new-expressions)
>>> +//                ::= Dc   # decltype(auto)
>>>  //                ::= Dn   # std::nullptr_t (i.e., decltype(nullptr))
>>>  //                ::= u <source-name>    # vendor extended type
>>>
>>> @@ -532,6 +507,10 @@ parse_builtin_type(const char* first, co
>>>                      db.names.push_back("auto");
>>>                      first += 2;
>>>                      break;
>>> +                case 'c':
>>> +                    db.names.push_back("decltype(auto)");
>>> +                    first += 2;
>>> +                    break;
>>>                  case 'n':
>>>                      db.names.push_back("std::nullptr_t");
>>>                      first += 2;
>>> @@ -1610,10 +1589,9 @@ parse_function_type(const char* first, c
>>>          const char* t = first+1;
>>>          if (t != last)
>>>          {
>>> -            bool externC = false;
>>>              if (*t == 'Y')
>>>              {
>>> -                externC = true;
>>> +                /* extern "C" */
>>>                  if (++t == last)
>>>                      return first;
>>>              }
>>> @@ -1707,7 +1685,7 @@ parse_pointer_to_member_type(const char*
>>>                  auto func = std::move(db.names.back());
>>>                  db.names.pop_back();
>>>                  auto class_type = std::move(db.names.back());
>>> -                if (func.second.front() == '(')
>>> +                if (!func.second.empty() && func.second.front() == '(')
>>>                  {
>>>                      db.names.back().first = std::move(func.first) + "("
>>> + class_type.move_full() + "::*";
>>>                      db.names.back().second = ")" +
>>> std::move(func.second);
>>> @@ -2054,7 +2032,8 @@ parse_type(const char* first, const char
>>>                                      db.names[k].first += " (";
>>>                                      db.names[k].second.insert(0, ")");
>>>                                  }
>>> -                                else if (db.names[k].second.front() ==
>>> '(')
>>> +                                else if (!db.names[k].second.empty() &&
>>> +                                          db.names[k].second.front() ==
>>> '(')
>>>                                  {
>>>                                      db.names[k].first += "(";
>>>                                      db.names[k].second.insert(0, ")");
>>> @@ -2081,7 +2060,8 @@ parse_type(const char* first, const char
>>>                                      db.names[k].first += " (";
>>>                                      db.names[k].second.insert(0, ")");
>>>                                  }
>>> -                                else if (db.names[k].second.front() ==
>>> '(')
>>> +                                else if (!db.names[k].second.empty() &&
>>> +                                          db.names[k].second.front() ==
>>> '(')
>>>                                  {
>>>                                      db.names[k].first += "(";
>>>                                      db.names[k].second.insert(0, ")");
>>> @@ -2115,7 +2095,8 @@ parse_type(const char* first, const char
>>>                                      db.names[k].first += " (";
>>>                                      db.names[k].second.insert(0, ")");
>>>                                  }
>>> -                                else if (db.names[k].second.front() ==
>>> '(')
>>> +                                else if (!db.names[k].second.empty() &&
>>> +                                          db.names[k].second.front() ==
>>> '(')
>>>                                  {
>>>                                      db.names[k].first += "(";
>>>                                      db.names[k].second.insert(0, ")");
>>> @@ -3933,7 +3914,8 @@ parse_template_args(const char* first, c
>>>
>>>  template <class C>
>>>  const char*
>>> -parse_nested_name(const char* first, const char* last, C& db)
>>> +parse_nested_name(const char* first, const char* last, C& db,
>>> +                  bool* ends_with_template_args)
>>>  {
>>>      if (first != last && *first == 'N')
>>>      {
>>> @@ -3941,15 +3923,15 @@ parse_nested_name(const char* first, con
>>>          const char* t0 = parse_cv_qualifiers(first+1, last, cv);
>>>          if (t0 == last)
>>>              return first;
>>> -        unsigned ref = 0;
>>> +        db.ref = 0;
>>>          if (*t0 == 'R')
>>>          {
>>> -            ref = 1;
>>> +            db.ref = 1;
>>>              ++t0;
>>>          }
>>>          else if (*t0 == 'O')
>>>          {
>>> -            ref = 2;
>>> +            db.ref = 2;
>>>              ++t0;
>>>          }
>>>          db.names.emplace_back();
>>> @@ -3964,8 +3946,10 @@ parse_nested_name(const char* first, con
>>>              return first;
>>>          }
>>>          bool pop_subs = false;
>>> +        bool component_ends_with_template_args = false;
>>>          while (*t0 != 'E')
>>>          {
>>> +            component_ends_with_template_args = false;
>>>              const char* t1;
>>>              switch (*t0)
>>>              {
>>> @@ -4035,6 +4019,7 @@ parse_nested_name(const char* first, con
>>>                      db.names.back().first += name;
>>>                      db.subs.push_back(typename C::sub_type(1,
>>> db.names.back(), db.names.get_allocator()));
>>>                      t0 = t1;
>>> +                    component_ends_with_template_args = true;
>>>                  }
>>>                  else
>>>                      return first;
>>> @@ -4063,10 +4048,11 @@ parse_nested_name(const char* first, con
>>>              }
>>>          }
>>>          first = t0 + 1;
>>> -        db.ref = ref;
>>>          db.cv = cv;
>>>          if (pop_subs && !db.subs.empty())
>>>              db.subs.pop_back();
>>> +        if (ends_with_template_args)
>>> +            *ends_with_template_args =
>>> component_ends_with_template_args;
>>>      }
>>>      return first;
>>>  }
>>> @@ -4114,7 +4100,8 @@ parse_discriminator(const char* first, c
>>>
>>>  template <class C>
>>>  const char*
>>> -parse_local_name(const char* first, const char* last, C& db)
>>> +parse_local_name(const char* first, const char* last, C& db,
>>> +                 bool* ends_with_template_args)
>>>  {
>>>      if (first != last && *first == 'Z')
>>>      {
>>> @@ -4136,7 +4123,8 @@ parse_local_name(const char* first, cons
>>>                      if (t1 != last && *t1 == '_')
>>>                      {
>>>                          t = t1 + 1;
>>> -                        t1 = parse_name(t, last, db);
>>> +                        t1 = parse_name(t, last, db,
>>> +                                        ends_with_template_args);
>>>                          if (t1 != t)
>>>                          {
>>>                              if (db.names.size() < 2)
>>> @@ -4154,7 +4142,8 @@ parse_local_name(const char* first, cons
>>>                  break;
>>>              default:
>>>                  {
>>> -                    const char* t1 = parse_name(t, last, db);
>>> +                    const char* t1 = parse_name(t, last, db,
>>> +
>>> ends_with_template_args);
>>>                      if (t1 != t)
>>>                      {
>>>                          // parse but ignore discriminator
>>> @@ -4186,7 +4175,8 @@ parse_local_name(const char* first, cons
>>>
>>>  template <class C>
>>>  const char*
>>> -parse_name(const char* first, const char* last, C& db)
>>> +parse_name(const char* first, const char* last, C& db,
>>> +           bool* ends_with_template_args)
>>>  {
>>>      if (last - first >= 2)
>>>      {
>>> @@ -4198,14 +4188,16 @@ parse_name(const char* first, const char
>>>          {
>>>          case 'N':
>>>            {
>>> -            const char* t1 = parse_nested_name(t0, last, db);
>>> +            const char* t1 = parse_nested_name(t0, last, db,
>>> +                                               ends_with_template_args);
>>>              if (t1 != t0)
>>>                  first = t1;
>>>              break;
>>>            }
>>>          case 'Z':
>>>            {
>>> -            const char* t1 = parse_local_name(t0, last, db);
>>> +            const char* t1 = parse_local_name(t0, last, db,
>>> +                                              ends_with_template_args);
>>>              if (t1 != t0)
>>>                  first = t1;
>>>              break;
>>> @@ -4230,6 +4222,8 @@ parse_name(const char* first, const char
>>>                          db.names.pop_back();
>>>                          db.names.back().first += tmp;
>>>                          first = t1;
>>> +                        if (ends_with_template_args)
>>> +                            *ends_with_template_args = true;
>>>                      }
>>>                  }
>>>                  else   // <unscoped-name>
>>> @@ -4250,6 +4244,8 @@ parse_name(const char* first, const char
>>>                          db.names.pop_back();
>>>                          db.names.back().first += tmp;
>>>                          first = t1;
>>> +                        if (ends_with_template_args)
>>> +                            *ends_with_template_args = true;
>>>                      }
>>>                  }
>>>              }
>>> @@ -4423,7 +4419,7 @@ parse_special_name(const char* first, co
>>>                  {
>>>                      if (db.names.empty())
>>>                          return first;
>>> -                    if (first[1] == 'v')
>>> +                    if (first[2] == 'v')
>>>                      {
>>>                          db.names.back().first.insert(0, "virtual thunk
>>> to ");
>>>                          first = t;
>>> @@ -4513,7 +4509,9 @@ parse_encoding(const char* first, const
>>>              break;
>>>          default:
>>>            {
>>> -            const char* t = parse_name(first, last, db);
>>> +            bool ends_with_template_args = false;
>>> +            const char* t = parse_name(first, last, db,
>>> +                                       &ends_with_template_args);
>>>              unsigned cv = db.cv;
>>>              unsigned ref = db.ref;
>>>              if (t != first)
>>> @@ -4529,8 +4527,7 @@ parse_encoding(const char* first, const
>>>                      const typename C::String& nm =
>>> db.names.back().first;
>>>                      if (nm.empty())
>>>                          return first;
>>> -                    if (!db.parsed_ctor_dtor_cv && nm.back() == '>' &&
>>> nm[nm.size()-2] != '-'
>>> -                                                                    &&
>>> nm[nm.size()-2] != '>')
>>> +                    if (!db.parsed_ctor_dtor_cv &&
>>> ends_with_template_args)
>>>                      {
>>>                          t2 = parse_type(t, last, db);
>>>                          if (t2 == t)
>>> @@ -4730,7 +4727,7 @@ class arena
>>>
>>>      std::size_t
>>>      align_up(std::size_t n) noexcept
>>> -        {return n + (alignment-1) & ~(alignment-1);}
>>> +        {return (n + (alignment-1)) & ~(alignment-1);}
>>>
>>>      bool
>>>      pointer_in_buffer(char* p) noexcept
>>> @@ -4866,32 +4863,33 @@ operator!=(const malloc_alloc<T>& x, con
>>>  const size_t bs = 4 * 1024;
>>>  template <class T> using Alloc = short_alloc<T, bs>;
>>>  template <class T> using Vector = std::vector<T, Alloc<T>>;
>>> -using String = std::basic_string<char, std::char_traits<char>,
>>> malloc_alloc<char>>;
>>>
>>> +template <class StrT>
>>>  struct string_pair
>>>  {
>>> -    String first;
>>> -    String second;
>>> +    StrT first;
>>> +    StrT second;
>>>
>>>      string_pair() = default;
>>> -    string_pair(String f) : first(std::move(f)) {}
>>> -    string_pair(String f, String s)
>>> +    string_pair(StrT f) : first(std::move(f)) {}
>>> +    string_pair(StrT f, StrT s)
>>>          : first(std::move(f)), second(std::move(s)) {}
>>>      template <size_t N>
>>>          string_pair(const char (&s)[N]) : first(s, N-1) {}
>>>
>>>      size_t size() const {return first.size() + second.size();}
>>> -    String full() const {return first + second;}
>>> -    String move_full() {return std::move(first) + std::move(second);}
>>> +    StrT full() const {return first + second;}
>>> +    StrT move_full() {return std::move(first) + std::move(second);}
>>>  };
>>>
>>>  struct Db
>>>  {
>>> -    typedef ::String String;
>>> -    typedef Vector<string_pair> sub_type;
>>> +    typedef std::basic_string<char, std::char_traits<char>,
>>> +                              malloc_alloc<char>> String;
>>> +    typedef Vector<string_pair<String>> sub_type;
>>>      typedef Vector<sub_type> template_param_type;
>>> -    Vector<string_pair> names;
>>> -    Vector<sub_type> subs;
>>> +    sub_type names;
>>> +    template_param_type subs;
>>>      Vector<template_param_type> template_param;
>>>      unsigned cv;
>>>      unsigned ref;
>>> @@ -4909,6 +4907,8 @@ struct Db
>>>      {}
>>>  };
>>>
>>> +}  // unnamed namespace
>>> +
>>>  char*
>>>  __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int*
>>> status)
>>>  {
>>> @@ -4976,410 +4976,4 @@ __cxa_demangle(const char* mangled_name,
>>>      return buf;
>>>  }
>>>
>>> -}
>>> -#endif
>>> -
>>> -
>>> -#include "llvm/ADT/DenseMap.h"
>>> -
>>> -#include "lldb/Core/ConstString.h"
>>> -#include "lldb/Core/Mangled.h"
>>> -#include "lldb/Core/RegularExpression.h"
>>> -#include "lldb/Core/Stream.h"
>>> -#include "lldb/Core/Timer.h"
>>> -#include "lldb/Target/CPPLanguageRuntime.h"
>>> -#include <ctype.h>
>>> -#include <string.h>
>>> -#include <stdlib.h>
>>> -
>>> -
>>> -using namespace lldb_private;
>>> -
>>> -static inline bool
>>> -cstring_is_mangled (const char *s)
>>> -{
>>> -    if (s)
>>> -#if defined(_MSC_VER)
>>> -        return (s[0] == '?');
>>> -#else
>>> -        return (s[0] == '_' && s[1] == 'Z');
>>> -#endif
>>> -    return false;
>>> -}
>>> -
>>> -static const ConstString &
>>> -get_demangled_name_without_arguments (const Mangled *obj)
>>> -{
>>> -    // This pair is <mangled name, demangled name without function
>>> arguments>
>>> -    static std::pair<ConstString, ConstString>
>>> g_most_recent_mangled_to_name_sans_args;
>>> -
>>> -    // Need to have the mangled & demangled names we're currently
>>> examining as statics
>>> -    // so we can return a const ref to them at the end of the func if
>>> we don't have
>>> -    // anything better.
>>> -    static ConstString g_last_mangled;
>>> -    static ConstString g_last_demangled;
>>> -
>>> -    ConstString mangled = obj->GetMangledName ();
>>> -    ConstString demangled = obj->GetDemangledName ();
>>> -
>>> -    if (mangled && g_most_recent_mangled_to_name_sans_args.first ==
>>> mangled)
>>> -    {
>>> -        return g_most_recent_mangled_to_name_sans_args.second;
>>> -    }
>>> -
>>> -    g_last_demangled = demangled;
>>> -    g_last_mangled = mangled;
>>> -
>>> -    const char *mangled_name_cstr = mangled.GetCString();
>>> -
>>> -    if (demangled && mangled_name_cstr && mangled_name_cstr[0])
>>> -    {
>>> -        if (mangled_name_cstr[0] == '_' && mangled_name_cstr[1] == 'Z'
>>> &&
>>> -            (mangled_name_cstr[2] != 'T' && // avoid virtual table, VTT
>>> structure, typeinfo structure, and typeinfo mangled_name
>>> -            mangled_name_cstr[2] != 'G' && // avoid guard variables
>>> -            mangled_name_cstr[2] != 'Z'))  // named local entities (if
>>> we eventually handle eSymbolTypeData, we will want this back)
>>> -        {
>>> -            CPPLanguageRuntime::MethodName cxx_method (demangled);
>>> -            if (!cxx_method.GetBasename().empty() &&
>>> !cxx_method.GetContext().empty())
>>> -            {
>>> -                std::string shortname = cxx_method.GetContext().str();
>>> -                shortname += "::";
>>> -                shortname += cxx_method.GetBasename().str();
>>> -                ConstString result(shortname.c_str());
>>> -                g_most_recent_mangled_to_name_sans_args.first = mangled;
>>> -                g_most_recent_mangled_to_name_sans_args.second = result;
>>> -                return g_most_recent_mangled_to_name_sans_args.second;
>>> -            }
>>> -        }
>>> -    }
>>> -
>>> -    if (demangled)
>>> -        return g_last_demangled;
>>> -    return g_last_mangled;
>>> -}
>>> -
>>> -#pragma mark Mangled
>>> -//----------------------------------------------------------------------
>>> -// Default constructor
>>> -//----------------------------------------------------------------------
>>> -Mangled::Mangled () :
>>> -    m_mangled(),
>>> -    m_demangled()
>>> -{
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// 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()
>>> -{
>>> -    if (s)
>>> -        SetValue(s, mangled);
>>> -}
>>> -
>>> -Mangled::Mangled (const ConstString &s) :
>>> -    m_mangled(),
>>> -    m_demangled()
>>> -{
>>> -    if (s)
>>> -        SetValue(s);
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Destructor
>>> -//----------------------------------------------------------------------
>>> -Mangled::~Mangled ()
>>> -{
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Convert to pointer operator. This allows code to check any Mangled
>>> -// objects to see if they contain anything valid using code such as:
>>> -//
>>> -//  Mangled mangled(...);
>>> -//  if (mangled)
>>> -//  { ...
>>> -//----------------------------------------------------------------------
>>> -Mangled::operator void* () const
>>> -{
>>> -    return (m_mangled) ? const_cast<Mangled*>(this) : NULL;
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Logical NOT operator. This allows code to check any Mangled
>>> -// objects to see if they are invalid using code such as:
>>> -//
>>> -//  Mangled mangled(...);
>>> -//  if (!file_spec)
>>> -//  { ...
>>> -//----------------------------------------------------------------------
>>> -bool
>>> -Mangled::operator! () const
>>> -{
>>> -    return !m_mangled;
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Clear the mangled and demangled values.
>>> -//----------------------------------------------------------------------
>>> -void
>>> -Mangled::Clear ()
>>> -{
>>> -    m_mangled.Clear();
>>> -    m_demangled.Clear();
>>> -}
>>> -
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Compare the the string values.
>>> -//----------------------------------------------------------------------
>>> -int
>>> -Mangled::Compare (const Mangled& a, const Mangled& b)
>>> -{
>>> -    return ConstString::Compare(a.GetName(ePreferMangled),
>>> a.GetName(ePreferMangled));
>>> -}
>>> -
>>> -
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Set the string value in this objects. If "mangled" is true, then
>>> -// the mangled named is set with the new value in "s", else the
>>> -// demangled name is set.
>>> -//----------------------------------------------------------------------
>>> -void
>>> -Mangled::SetValue (const ConstString &s, bool mangled)
>>> -{
>>> -    if (s)
>>> -    {
>>> -        if (mangled)
>>> -        {
>>> -            m_demangled.Clear();
>>> -            m_mangled = s;
>>> -        }
>>> -        else
>>> -        {
>>> -            m_demangled = s;
>>> -            m_mangled.Clear();
>>> -        }
>>> -    }
>>> -    else
>>> -    {
>>> -        m_demangled.Clear();
>>> -        m_mangled.Clear();
>>> -    }
>>> -}
>>> -
>>> -void
>>> -Mangled::SetValue (const ConstString &name)
>>> -{
>>> -    if (name)
>>> -    {
>>> -        if (cstring_is_mangled(name.GetCString()))
>>> -        {
>>> -            m_demangled.Clear();
>>> -            m_mangled = name;
>>> -        }
>>> -        else
>>> -        {
>>> -            m_demangled = name;
>>> -            m_mangled.Clear();
>>> -        }
>>> -    }
>>> -    else
>>> -    {
>>> -        m_demangled.Clear();
>>> -        m_mangled.Clear();
>>> -    }
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Generate the demangled name on demand using this accessor. Code in
>>> -// this class will need to use this accessor if it wishes to decode
>>> -// the demangled name. The result is cached and will be kept until a
>>> -// new string value is supplied to this object, or until the end of the
>>> -// object's lifetime.
>>> -//----------------------------------------------------------------------
>>> -const ConstString&
>>> -Mangled::GetDemangledName () const
>>> -{
>>> -    // Check to make sure we have a valid mangled name and that we
>>> -    // haven't already decoded our mangled name.
>>> -    if (m_mangled && !m_demangled)
>>> -    {
>>> -        // We need to generate and cache the demangled name.
>>> -        Timer scoped_timer (__PRETTY_FUNCTION__,
>>> -                            "Mangled::GetDemangledName (m_mangled =
>>> %s)",
>>> -                            m_mangled.GetCString());
>>> -
>>> -        // Don't bother running anything that isn't mangled
>>> -        const char *mangled_cstr = m_mangled.GetCString();
>>> -        if (cstring_is_mangled(mangled_cstr))
>>> -        {
>>> -            if (!m_mangled.GetMangledCounterpart(m_demangled))
>>> -            {
>>> -                // We didn't already mangle this name, demangle it and
>>> if all goes well
>>> -                // add it to our map.
>>> -#ifdef LLDB_USE_BUILTIN_DEMANGLER
>>> -                // Try to use the fast-path demangler first for the
>>> -                // performance win, falling back to the full demangler
>>> only
>>> -                // when necessary
>>> -                char *demangled_name = FastDemangle (mangled_cstr,
>>> -
>>>  m_mangled.GetLength());
>>> -                if (!demangled_name)
>>> -                    demangled_name = __cxa_demangle (mangled_cstr,
>>> NULL, NULL, NULL);
>>> -#elif defined(_MSC_VER)
>>> -                char *demangled_name = (char *)::malloc(1024);
>>> -                ::ZeroMemory(demangled_name, 1024);
>>> -                DWORD result = ::UnDecorateSymbolName(mangled_cstr,
>>> demangled_name, 1023,
>>> -
>>> UNDNAME_NO_ACCESS_SPECIFIERS |       // Strip public, private, protected
>>> keywords
>>> -
>>> UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc
>>> keywords
>>> -
>>> UNDNAME_NO_THROW_SIGNATURES |    // Strip throw() specifications
>>> -
>>> UNDNAME_NO_MEMBER_TYPE |         // Strip virtual, static, etc specifiers
>>> -
>>> UNDNAME_NO_MS_KEYWORDS           // Strip all MS extension keywords
>>> -                                                      );
>>> -                if (result == 0)
>>> -                {
>>> -                    free (demangled_name);
>>> -                    demangled_name = nullptr;
>>> -                }
>>> -#else
>>> -                char *demangled_name = abi::__cxa_demangle
>>> (mangled_cstr, NULL, NULL, NULL);
>>> -#endif
>>> -
>>> -                if (demangled_name)
>>> -                {
>>> -
>>> m_demangled.SetCStringWithMangledCounterpart(demangled_name, m_mangled);
>>> -                    free (demangled_name);
>>> -                }
>>> -            }
>>> -        }
>>> -        if (!m_demangled)
>>> -        {
>>> -            // Set the demangled string to the empty string to indicate
>>> we
>>> -            // tried to parse it once and failed.
>>> -            m_demangled.SetCString("");
>>> -        }
>>> -    }
>>> -
>>> -    return m_demangled;
>>> -}
>>> -
>>> -
>>> -bool
>>> -Mangled::NameMatches (const RegularExpression& regex) const
>>> -{
>>> -    if (m_mangled && regex.Execute (m_mangled.AsCString()))
>>> -        return true;
>>> -
>>> -    if (GetDemangledName() && regex.Execute (m_demangled.AsCString()))
>>> -        return true;
>>> -    return false;
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Get the demangled name if there is one, else return the mangled name.
>>> -//----------------------------------------------------------------------
>>> -const ConstString&
>>> -Mangled::GetName (Mangled::NamePreference preference) const
>>> -{
>>> -    if (preference == ePreferDemangledWithoutArguments)
>>> -    {
>>> -        // Call the accessor to make sure we get a demangled name in
>>> case
>>> -        // it hasn't been demangled yet...
>>> -        GetDemangledName();
>>> -
>>> -        return get_demangled_name_without_arguments (this);
>>> -    }
>>> -    if (preference == ePreferDemangled)
>>> -    {
>>> -        // Call the accessor to make sure we get a demangled name in
>>> case
>>> -        // it hasn't been demangled yet...
>>> -        if (GetDemangledName())
>>> -            return m_demangled;
>>> -        return m_mangled;
>>> -    }
>>> -    else
>>> -    {
>>> -        if (m_mangled)
>>> -            return m_mangled;
>>> -        return GetDemangledName();
>>> -    }
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Dump a Mangled object to stream "s". We don't force our
>>> -// demangled name to be computed currently (we don't use the accessor).
>>> -//----------------------------------------------------------------------
>>> -void
>>> -Mangled::Dump (Stream *s) const
>>> -{
>>> -    if (m_mangled)
>>> -    {
>>> -        *s << ", mangled = " << m_mangled;
>>> -    }
>>> -    if (m_demangled)
>>> -    {
>>> -        const char * demangled = m_demangled.AsCString();
>>> -        s->Printf(", demangled = %s", demangled[0] ? demangled :
>>> "<error>");
>>> -    }
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Dumps a debug version of this string with extra object and state
>>> -// information to stream "s".
>>> -//----------------------------------------------------------------------
>>> -void
>>> -Mangled::DumpDebug (Stream *s) const
>>> -{
>>> -    s->Printf("%*p: Mangled mangled = ", static_cast<int>(sizeof(void*)
>>> * 2),
>>> -              static_cast<const void*>(this));
>>> -    m_mangled.DumpDebug(s);
>>> -    s->Printf(", demangled = ");
>>> -    m_demangled.DumpDebug(s);
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Return the size in byte that this object takes in memory. The size
>>> -// includes the size of the objects it owns, and not the strings that
>>> -// it references because they are shared strings.
>>> -//----------------------------------------------------------------------
>>> -size_t
>>> -Mangled::MemorySize () const
>>> -{
>>> -    return m_mangled.MemorySize() + m_demangled.MemorySize();
>>> -}
>>> -
>>> -lldb::LanguageType
>>> -Mangled::GetLanguage ()
>>> -{
>>> -    ConstString mangled = GetMangledName();
>>> -    if (mangled)
>>> -    {
>>> -        if (GetDemangledName())
>>> -        {
>>> -            if (cstring_is_mangled(mangled.GetCString()))
>>> -                return lldb::eLanguageTypeC_plus_plus;
>>> -        }
>>> -    }
>>> -    return  lldb::eLanguageTypeUnknown;
>>> -}
>>> -
>>> -//----------------------------------------------------------------------
>>> -// Dump OBJ to the supplied stream S.
>>> -//----------------------------------------------------------------------
>>> -Stream&
>>> -operator << (Stream& s, const Mangled& obj)
>>> -{
>>> -    if (obj.GetMangledName())
>>> -        s << "mangled = '" << obj.GetMangledName() << "'";
>>> -
>>> -    const ConstString& demangled = obj.GetDemangledName();
>>> -    if (demangled)
>>> -        s << ", demangled = '" << demangled << '\'';
>>> -    else
>>> -        s << ", demangled = <error>";
>>> -    return s;
>>> -}
>>> +}  // lldb_private
>>>
>>> Modified: lldb/trunk/source/Core/Mangled.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=238459&r1=238458&r2=238459&view=diff
>>>
>>> ==============================================================================
>>> --- lldb/trunk/source/Core/Mangled.cpp (original)
>>> +++ lldb/trunk/source/Core/Mangled.cpp Thu May 28 14:15:15 2015
>>> @@ -23,4960 +23,9 @@
>>>
>>>  // Provide a fast-path demangler implemented in FastDemangle.cpp until
>>> it can
>>>  // replace the existing C++ demangler with a complete implementation
>>> -namespace lldb_private
>>> -{
>>> -    extern char * FastDemangle (const char * mangled_name,
>>> -                                long mangled_name_length);
>>> -}
>>> +#include "lldb/Core/FastDemangle.h"
>>> +#include "lldb/Core/CxaDemangle.h"
>>>
>>> -//----------------------------------------------------------------------
>>> -// Inlined copy of:
>>> -//
>>> http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp
>>> -// revision 199944.
>>> -//
>>> -// Changes include:
>>> -// - remove the "__cxxabiv1" namespace
>>> -// - stripped GCC attributes()
>>> -// - removed extern "C" from the cxa_demangle function
>>> -// - Changed the scope of the unnamed namespace to include cxa_demangle
>>> -//   function.
>>> -// - Added "#undef _LIBCPP_EXTERN_TEMPLATE" to avoid warning
>>> -//----------------------------------------------------------------------
>>> -
>>> -#undef _LIBCPP_EXTERN_TEMPLATE // Avoid warning below
>>> -
>>> -//===-------------------------- cxa_demangle.cpp
>>> --------------------------===//
>>> -//
>>> -//                     The LLVM Compiler Infrastructure
>>> -//
>>> -// This file is dual licensed under the MIT and the University of
>>> Illinois Open
>>> -// Source Licenses. See LICENSE.TXT for details.
>>> -//
>>>
>>> -//===----------------------------------------------------------------------===//
>>> -
>>> -#define _LIBCPP_EXTERN_TEMPLATE(...)
>>> -#define _LIBCPP_NO_EXCEPTIONS
>>> -
>>> -#include <vector>
>>> -#include <algorithm>
>>> -#include <string>
>>> -#include <numeric>
>>> -#include <cstdlib>
>>> -#include <cstring>
>>> -#include <cctype>
>>> -
>>> -
>>> -namespace
>>> -{
>>> -
>>> -enum
>>> -{
>>> -    unknown_error = -4,
>>> -    invalid_args = -3,
>>> -    invalid_mangled_name,
>>> -    memory_alloc_failure,
>>> -    success
>>> -};
>>> -
>>> -template <class C>
>>> -    const char* parse_type(const char* first, const char* last, C& db);
>>> -template <class C>
>>> -    const char* parse_encoding(const char* first, const char* last, C&
>>> db);
>>> -template <class C>
>>> -    const char* parse_name(const char* first, const char* last, C& db);
>>> -template <class C>
>>> -    const char* parse_expression(const char* first, const char* last,
>>> C& db);
>>> -template <class C>
>>> -    const char* parse_template_args(const char* first, const char*
>>> last, C& db);
>>> -template <class C>
>>> -    const char* parse_operator_name(const char* first, const char*
>>> last, C& db);
>>> -template <class C>
>>> -    const char* parse_unqualified_name(const char* first, const char*
>>> last, C& db);
>>> -template <class C>
>>> -    const char* parse_decltype(const char* first, const char* last, C&
>>> db);
>>> -
>>> -template <class C>
>>> -void
>>> -print_stack(const C& db)
>>> -{
>>> -    printf("---------\n");
>>> -    printf("names:\n");
>>> -    for (auto& s : db.names)
>>> -        printf("{%s#%s}\n", s.first.c_str(), s.second.c_str());
>>> -    int i = -1;
>>> -    printf("subs:\n");
>>> -    for (auto& v : db.subs)
>>> -    {
>>> -        if (i >= 0)
>>> -            printf("S%i_ = {", i);
>>> -        else
>>> -            printf("S_  = {");
>>> -        for (auto& s : v)
>>> -            printf("{%s#%s}", s.first.c_str(), s.second.c_str());
>>> -        printf("}\n");
>>> -        ++i;
>>> -    }
>>> -    printf("template_param:\n");
>>> -    for (auto& t : db.template_param)
>>> -    {
>>> -        printf("--\n");
>>> -        i = -1;
>>> -        for (auto& v : t)
>>> -        {
>>> -            if (i >= 0)
>>> -                printf("T%i_ = {", i);
>>> -            else
>>> -                printf("T_  = {");
>>> -            for (auto& s : v)
>>> -                printf("{%s#%s}", s.first.c_str(), s.second.c_str());
>>> -            printf("}\n");
>>> -            ++i;
>>> -        }
>>> -    }
>>> -    printf("---------\n\n");
>>> -}
>>> -
>>> -template <class C>
>>> -void
>>> -print_state(const char* msg, const char* first, const char* last, const
>>> C& db)
>>> -{
>>> -    printf("%s: ", msg);
>>> -    for (; first != last; ++first)
>>> -        printf("%c", *first);
>>> -    printf("\n");
>>> -    print_stack(db);
>>> -}
>>> -
>>> -// <number> ::= [n] <non-negative decimal integer>
>>> -
>>> -const char*
>>> -parse_number(const char* first, const char* last)
>>> -{
>>> -    if (first != last)
>>> -    {
>>> -        const char* t = first;
>>> -        if (*t == 'n')
>>> -            ++t;
>>> -        if (t != last)
>>> -        {
>>> -            if (*t == '0')
>>> -            {
>>> -                first = t+1;
>>> -            }
>>> -            else if ('1' <= *t && *t <= '9')
>>> -            {
>>> -                first = t+1;
>>> -                while (first != last && std::isdigit(*first))
>>> -                    ++first;
>>> -            }
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -template <class Float>
>>> -struct float_data;
>>> -
>>> -template <>
>>> -struct float_data<float>
>>> -{
>>> -    static const size_t mangled_size = 8;
>>> -    static const size_t max_demangled_size = 24;
>>> -    static constexpr const char* spec = "%af";
>>> -};
>>> -
>>> -constexpr const char* float_data<float>::spec;
>>> -
>>> -template <>
>>> -struct float_data<double>
>>> -{
>>> -    static const size_t mangled_size = 16;
>>> -    static const size_t max_demangled_size = 32;
>>> -    static constexpr const char* spec = "%a";
>>> -};
>>> -
>>> -constexpr const char* float_data<double>::spec;
>>> -
>>> -template <>
>>> -struct float_data<long double>
>>> -{
>>> -    static const size_t mangled_size = 20;  // May need to be adjusted
>>> to 16 or 24 on other platforms
>>> -    static const size_t max_demangled_size = 40;
>>> -    static constexpr const char* spec = "%LaL";
>>> -};
>>> -
>>> -constexpr const char* float_data<long double>::spec;
>>> -
>>> -template <class Float, class C>
>>> -const char*
>>> -parse_floating_number(const char* first, const char* last, C& db)
>>> -{
>>> -    const size_t N = float_data<Float>::mangled_size;
>>> -    if (static_cast<std::size_t>(last - first) > N)
>>> -    {
>>> -        last = first + N;
>>> -        union
>>> -        {
>>> -            Float value;
>>> -            char buf[sizeof(Float)];
>>> -        };
>>> -        const char* t = first;
>>> -        char* e = buf;
>>> -        for (; t != last; ++t, ++e)
>>> -        {
>>> -            if (!isxdigit(*t))
>>> -                return first;
>>> -            unsigned d1 = isdigit(*t) ? static_cast<unsigned>(*t - '0')
>>> :
>>> -                                        static_cast<unsigned>(*t - 'a'
>>> + 10);
>>> -            ++t;
>>> -            unsigned d0 = isdigit(*t) ? static_cast<unsigned>(*t - '0')
>>> :
>>> -                                        static_cast<unsigned>(*t - 'a'
>>> + 10);
>>> -            *e = static_cast<char>((d1 << 4) + d0);
>>> -        }
>>> -        if (*t == 'E')
>>> -        {
>>> -#if __LITTLE_ENDIAN__
>>> -            std::reverse(buf, e);
>>> -#endif
>>> -            char num[float_data<Float>::max_demangled_size] = {0};
>>> -            int n = snprintf(num, sizeof(num), float_data<Float>::spec,
>>> value);
>>> -            if (static_cast<std::size_t>(n) >= sizeof(num))
>>> -                return first;
>>> -            db.names.push_back(typename C::String(num,
>>> static_cast<std::size_t>(n)));
>>> -            first = t+1;
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -// <source-name> ::= <positive length number> <identifier>
>>> -
>>> -template <class C>
>>> -const char*
>>> -parse_source_name(const char* first, const char* last, C& db)
>>> -{
>>> -    if (first != last)
>>> -    {
>>> -        char c = *first;
>>> -        if (isdigit(c) && first+1 != last)
>>> -        {
>>> -            const char* t = first+1;
>>> -            size_t n = static_cast<size_t>(c - '0');
>>> -            for (c = *t; isdigit(c); c = *t)
>>> -            {
>>> -                n = n * 10 + static_cast<size_t>(c - '0');
>>> -                if (++t == last)
>>> -                    return first;
>>> -            }
>>> -            if (static_cast<size_t>(last - t) >= n)
>>> -            {
>>> -                typename C::String r(t, n);
>>> -                if (r.substr(0, 10) == "_GLOBAL__N")
>>> -                    db.names.push_back("(anonymous namespace)");
>>> -                else
>>> -                    db.names.push_back(std::move(r));
>>> -                first = t + n;
>>> -            }
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -// <substitution> ::= S <seq-id> _
>>> -//                ::= S_
>>> -// <substitution> ::= Sa # ::std::allocator
>>> -// <substitution> ::= Sb # ::std::basic_string
>>> -// <substitution> ::= Ss # ::std::basic_string < char,
>>> -//
>>>  ::std::char_traits<char>,
>>> -//                                               ::std::allocator<char>
>>> >
>>> -// <substitution> ::= Si # ::std::basic_istream<char,
>>> std::char_traits<char> >
>>> -// <substitution> ::= So # ::std::basic_ostream<char,
>>> std::char_traits<char> >
>>> -// <substitution> ::= Sd # ::std::basic_iostream<char,
>>> std::char_traits<char> >
>>> -
>>> -template <class C>
>>> -const char*
>>> -parse_substitution(const char* first, const char* last, C& db)
>>> -{
>>> -    if (last - first >= 2)
>>> -    {
>>> -        if (*first == 'S')
>>> -        {
>>> -            switch (first[1])
>>> -            {
>>> -            case 'a':
>>> -                db.names.push_back("std::allocator");
>>> -                first += 2;
>>> -                break;
>>> -            case 'b':
>>> -                db.names.push_back("std::basic_string");
>>> -                first += 2;
>>> -                break;
>>> -            case 's':
>>> -                db.names.push_back("std::string");
>>> -                first += 2;
>>> -                break;
>>> -            case 'i':
>>> -                db.names.push_back("std::istream");
>>> -                first += 2;
>>> -                break;
>>> -            case 'o':
>>> -                db.names.push_back("std::ostream");
>>> -                first += 2;
>>> -                break;
>>> -            case 'd':
>>> -                db.names.push_back("std::iostream");
>>> -                first += 2;
>>> -                break;
>>> -            case '_':
>>> -                if (!db.subs.empty())
>>> -                {
>>> -                    for (const auto& n : db.subs.front())
>>> -                        db.names.push_back(n);
>>> -                    first += 2;
>>> -                }
>>> -                break;
>>> -            default:
>>> -                if (std::isdigit(first[1]) || std::isupper(first[1]))
>>> -                {
>>> -                    size_t sub = 0;
>>> -                    const char* t = first+1;
>>> -                    if (std::isdigit(*t))
>>> -                        sub = static_cast<size_t>(*t - '0');
>>> -                    else
>>> -                        sub = static_cast<size_t>(*t - 'A') + 10;
>>> -                    for (++t; t != last && (std::isdigit(*t) ||
>>> std::isupper(*t)); ++t)
>>> -                    {
>>> -                        sub *= 36;
>>> -                        if (std::isdigit(*t))
>>> -                            sub += static_cast<size_t>(*t - '0');
>>> -                        else
>>> -                            sub += static_cast<size_t>(*t - 'A') + 10;
>>> -                    }
>>> -                    if (t == last || *t != '_')
>>> -                        return first;
>>> -                    ++sub;
>>> -                    if (sub < db.subs.size())
>>> -                    {
>>> -                        for (const auto& n : db.subs[sub])
>>> -                            db.names.push_back(n);
>>> -                        first = t+1;
>>> -                    }
>>> -                }
>>> -                break;
>>> -            }
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -// <builtin-type> ::= v    # void
>>> -//                ::= w    # wchar_t
>>> -//                ::= b    # bool
>>> -//                ::= c    # char
>>> -//                ::= a    # signed char
>>> -//                ::= h    # unsigned char
>>> -//                ::= s    # short
>>> -//                ::= t    # unsigned short
>>> -//                ::= i    # int
>>> -//                ::= j    # unsigned int
>>> -//                ::= l    # long
>>> -//                ::= m    # unsigned long
>>> -//                ::= x    # long long, __int64
>>> -//                ::= y    # unsigned long long, __int64
>>> -//                ::= n    # __int128
>>> -//                ::= o    # unsigned __int128
>>> -//                ::= f    # float
>>> -//                ::= d    # double
>>> -//                ::= e    # long double, __float80
>>> -//                ::= g    # __float128
>>> -//                ::= z    # ellipsis
>>> -//                ::= Dd   # IEEE 754r decimal floating point (64 bits)
>>> -//                ::= De   # IEEE 754r decimal floating point (128 bits)
>>> -//                ::= Df   # IEEE 754r decimal floating point (32 bits)
>>> -//                ::= Dh   # IEEE 754r half-precision floating point
>>> (16 bits)
>>> -//                ::= Di   # char32_t
>>> -//                ::= Ds   # char16_t
>>> -//                ::= Da   # auto (in dependent new-expressions)
>>> -//                ::= Dn   # std::nullptr_t (i.e., decltype(nullptr))
>>> -//                ::= u <source-name>    # vendor extended type
>>> -
>>> -template <class C>
>>> -const char*
>>> -parse_builtin_type(const char* first, const char* last, C& db)
>>> -{
>>> -    if (first != last)
>>> -    {
>>> -        switch (*first)
>>> -        {
>>> -        case 'v':
>>> -            db.names.push_back("void");
>>> -            ++first;
>>> -            break;
>>> -        case 'w':
>>> -            db.names.push_back("wchar_t");
>>> -            ++first;
>>> -            break;
>>> -        case 'b':
>>> -            db.names.push_back("bool");
>>> -            ++first;
>>> -            break;
>>> -        case 'c':
>>> -            db.names.push_back("char");
>>> -            ++first;
>>> -            break;
>>> -        case 'a':
>>> -            db.names.push_back("signed char");
>>> -            ++first;
>>> -            break;
>>> -        case 'h':
>>> -            db.names.push_back("unsigned char");
>>> -            ++first;
>>> -            break;
>>> -        case 's':
>>> -            db.names.push_back("short");
>>> -            ++first;
>>> -            break;
>>> -        case 't':
>>> -            db.names.push_back("unsigned short");
>>> -            ++first;
>>> -            break;
>>> -        case 'i':
>>> -            db.names.push_back("int");
>>> -            ++first;
>>> -            break;
>>> -        case 'j':
>>> -            db.names.push_back("unsigned int");
>>> -            ++first;
>>> -            break;
>>> -        case 'l':
>>> -            db.names.push_back("long");
>>> -            ++first;
>>> -            break;
>>> -        case 'm':
>>> -            db.names.push_back("unsigned long");
>>> -            ++first;
>>> -            break;
>>> -        case 'x':
>>> -            db.names.push_back("long long");
>>> -            ++first;
>>> -            break;
>>> -        case 'y':
>>> -            db.names.push_back("unsigned long long");
>>> -            ++first;
>>> -            break;
>>> -        case 'n':
>>> -            db.names.push_back("__int128");
>>> -            ++first;
>>> -            break;
>>> -        case 'o':
>>> -            db.names.push_back("unsigned __int128");
>>> -            ++first;
>>> -            break;
>>> -        case 'f':
>>> -            db.names.push_back("float");
>>> -            ++first;
>>> -            break;
>>> -        case 'd':
>>> -            db.names.push_back("double");
>>> -            ++first;
>>> -            break;
>>> -        case 'e':
>>> -            db.names.push_back("long double");
>>> -            ++first;
>>> -            break;
>>> -        case 'g':
>>> -            db.names.push_back("__float128");
>>> -            ++first;
>>> -            break;
>>> -        case 'z':
>>> -            db.names.push_back("...");
>>> -            ++first;
>>> -            break;
>>> -        case 'u':
>>> -            {
>>> -                const char*t = parse_source_name(first+1, last, db);
>>> -                if (t != first+1)
>>> -                    first = t;
>>> -            }
>>> -            break;
>>> -        case 'D':
>>> -            if (first+1 != last)
>>> -            {
>>> -                switch (first[1])
>>> -                {
>>> -                case 'd':
>>> -                    db.names.push_back("decimal64");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 'e':
>>> -                    db.names.push_back("decimal128");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 'f':
>>> -                    db.names.push_back("decimal32");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 'h':
>>> -                    db.names.push_back("decimal16");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 'i':
>>> -                    db.names.push_back("char32_t");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 's':
>>> -                    db.names.push_back("char16_t");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 'a':
>>> -                    db.names.push_back("auto");
>>> -                    first += 2;
>>> -                    break;
>>> -                case 'n':
>>> -                    db.names.push_back("std::nullptr_t");
>>> -                    first += 2;
>>> -                    break;
>>> -                }
>>> -            }
>>> -            break;
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -// <CV-qualifiers> ::= [r] [V] [K]
>>> -
>>> -const char*
>>> -parse_cv_qualifiers(const char* first, const char* last, unsigned& cv)
>>> -{
>>> -    cv = 0;
>>> -    if (first != last)
>>> -    {
>>> -        if (*first == 'r')
>>> -        {
>>> -            cv |= 4;
>>> -            ++first;
>>> -        }
>>> -        if (*first == 'V')
>>> -        {
>>> -            cv |= 2;
>>> -            ++first;
>>> -        }
>>> -        if (*first == 'K')
>>> -        {
>>> -            cv |= 1;
>>> -            ++first;
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -// <template-param> ::= T_    # first template parameter
>>> -//                  ::= T <parameter-2 non-negative number> _
>>> -
>>> -template <class C>
>>> -const char*
>>> -parse_template_param(const char* first, const char* last, C& db)
>>> -{
>>> -    if (last - first >= 2)
>>> -    {
>>> -        if (*first == 'T')
>>> -        {
>>> -            if (first[1] == '_')
>>> -            {
>>> -                if (db.template_param.empty())
>>> -                    return first;
>>> -                if (!db.template_param.back().empty())
>>> -                {
>>> -                    for (auto& t : db.template_param.back().front())
>>> -                        db.names.push_back(t);
>>> -                    first += 2;
>>> -                }
>>> -                else
>>> -                {
>>> -                    db.names.push_back("T_");
>>> -                    first += 2;
>>> -                    db.fix_forward_references = true;
>>> -                }
>>> -            }
>>> -            else if (isdigit(first[1]))
>>> -            {
>>> -                const char* t = first+1;
>>> -                size_t sub = static_cast<size_t>(*t - '0');
>>> -                for (++t; t != last && isdigit(*t); ++t)
>>> -                {
>>> -                    sub *= 10;
>>> -                    sub += static_cast<size_t>(*t - '0');
>>> -                }
>>> -                if (t == last || *t != '_' || db.template_param.empty())
>>> -                    return first;
>>> -                ++sub;
>>> -                if (sub < db.template_param.back().size())
>>> -                {
>>> -                    for (auto& temp : db.template_param.back()[sub])
>>> -                        db.names.push_back(temp);
>>> -                    first = t+1;
>>> -                }
>>> -                else
>>> -                {
>>> -                    db.names.push_back(typename C::String(first, t+1));
>>> -                    first = t+1;
>>> -                    db.fix_forward_references = true;
>>> -                }
>>> -            }
>>> -        }
>>> -    }
>>> -    return first;
>>> -}
>>> -
>>> -// cc <type> <expression>                               #
>>> const_cast<type> (expression)
>>> -
>>> -template <class C>
>>> -const char*
>>> -parse_const_cast_expr(const char* first, c
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150528/09e6260e/attachment.html>


More information about the lldb-commits mailing list