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