xref: /freebsd/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/Generic.cpp (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- Generic.cpp ------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===---------------------------------------------------------------------===//
8 
9 #include "Generic.h"
10 #include "LibStdcpp.h"
11 #include "MsvcStl.h"
12 
GetDesugaredSmartPointerValue(ValueObject & ptr,ValueObject & container)13 lldb::ValueObjectSP lldb_private::formatters::GetDesugaredSmartPointerValue(
14     ValueObject &ptr, ValueObject &container) {
15   auto container_type = container.GetCompilerType().GetNonReferenceType();
16   if (!container_type)
17     return nullptr;
18 
19   auto arg = container_type.GetTypeTemplateArgument(0);
20   if (!arg)
21     // If there isn't enough debug info, use the pointer type as is
22     return ptr.GetSP();
23 
24   return ptr.Cast(arg.GetPointerType());
25 }
26