@@ -1697,65 +1697,88 @@ bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
1697
1697
return file_path.contains (" /usr/include/c++/" );
1698
1698
}
1699
1699
1700
+ static VariableListSP GetFunctionVariableList (const SymbolContext &sc) {
1701
+ assert (sc.function );
1702
+
1703
+ if (sc.block )
1704
+ if (Block *inline_block = sc.block ->GetContainingInlinedBlock ())
1705
+ return inline_block->GetBlockVariableList (true );
1706
+
1707
+ return sc.function ->GetBlock (true ).GetBlockVariableList (true );
1708
+ }
1709
+
1710
+ static char const *GetInlinedFunctionName (const SymbolContext &sc) {
1711
+ if (!sc.block )
1712
+ return nullptr ;
1713
+
1714
+ const Block *inline_block = sc.block ->GetContainingInlinedBlock ();
1715
+ if (!inline_block)
1716
+ return nullptr ;
1717
+
1718
+ const InlineFunctionInfo *inline_info =
1719
+ inline_block->GetInlinedFunctionInfo ();
1720
+ if (!inline_info)
1721
+ return nullptr ;
1722
+
1723
+ return inline_info->GetName ().AsCString (nullptr );
1724
+ }
1725
+
1726
+ static bool PrintFunctionNameWithArgs (Stream &s,
1727
+ const ExecutionContext *exe_ctx,
1728
+ const SymbolContext &sc) {
1729
+ assert (sc.function );
1730
+
1731
+ ExecutionContextScope *exe_scope =
1732
+ exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr ;
1733
+
1734
+ const char *cstr = sc.function ->GetName ().AsCString (nullptr );
1735
+ if (!cstr)
1736
+ return false ;
1737
+
1738
+ if (const char *inlined_name = GetInlinedFunctionName (sc)) {
1739
+ s.PutCString (cstr);
1740
+ s.PutCString (" [inlined] " );
1741
+ cstr = inlined_name;
1742
+ }
1743
+
1744
+ VariableList args;
1745
+ if (auto variable_list_sp = GetFunctionVariableList (sc))
1746
+ variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1747
+ args);
1748
+
1749
+ if (args.GetSize () > 0 ) {
1750
+ PrettyPrintFunctionNameWithArgs (s, cstr, exe_scope, args);
1751
+ } else {
1752
+ s.PutCString (cstr);
1753
+ }
1754
+
1755
+ return true ;
1756
+ }
1757
+
1700
1758
bool CPlusPlusLanguage::GetFunctionDisplayName (
1701
1759
const SymbolContext *sc, const ExecutionContext *exe_ctx,
1702
1760
FunctionNameRepresentation representation, Stream &s) {
1703
1761
switch (representation) {
1704
1762
case FunctionNameRepresentation::eNameWithArgs: {
1763
+ assert (sc);
1764
+
1705
1765
// Print the function name with arguments in it
1706
- if (sc->function ) {
1707
- ExecutionContextScope *exe_scope =
1708
- exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr ;
1709
- const char *cstr = sc->function ->GetName ().AsCString (nullptr );
1710
- if (cstr) {
1711
- const InlineFunctionInfo *inline_info = nullptr ;
1712
- VariableListSP variable_list_sp;
1713
- bool get_function_vars = true ;
1714
- if (sc->block ) {
1715
- Block *inline_block = sc->block ->GetContainingInlinedBlock ();
1716
-
1717
- if (inline_block) {
1718
- get_function_vars = false ;
1719
- inline_info = inline_block->GetInlinedFunctionInfo ();
1720
- if (inline_info)
1721
- variable_list_sp = inline_block->GetBlockVariableList (true );
1722
- }
1723
- }
1724
-
1725
- if (get_function_vars) {
1726
- variable_list_sp =
1727
- sc->function ->GetBlock (true ).GetBlockVariableList (true );
1728
- }
1729
-
1730
- if (inline_info) {
1731
- s.PutCString (cstr);
1732
- s.PutCString (" [inlined] " );
1733
- cstr = inline_info->GetName ().GetCString ();
1734
- }
1735
-
1736
- VariableList args;
1737
- if (variable_list_sp)
1738
- variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1739
- args);
1740
- if (args.GetSize () > 0 ) {
1741
- if (!PrettyPrintFunctionNameWithArgs (s, cstr, exe_scope, args))
1742
- return false ;
1743
- } else {
1744
- s.PutCString (cstr);
1745
- }
1746
- return true ;
1747
- }
1748
- } else if (sc->symbol ) {
1749
- const char *cstr = sc->symbol ->GetName ().AsCString (nullptr );
1750
- if (cstr) {
1751
- s.PutCString (cstr);
1752
- return true ;
1753
- }
1754
- }
1755
- } break ;
1756
- default :
1766
+ if (sc->function )
1767
+ return PrintFunctionNameWithArgs (s, exe_ctx, *sc);
1768
+
1769
+ if (!sc->symbol )
1770
+ return false ;
1771
+
1772
+ const char *cstr = sc->symbol ->GetName ().AsCString (nullptr );
1773
+ if (!cstr)
1774
+ return false ;
1775
+
1776
+ s.PutCString (cstr);
1777
+
1778
+ return true ;
1779
+ }
1780
+ case FunctionNameRepresentation::eNameWithNoArgs:
1781
+ case FunctionNameRepresentation::eName:
1757
1782
return false ;
1758
1783
}
1759
-
1760
- return false ;
1761
1784
}
0 commit comments