summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp')
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index 932db17b964a5..eca36fff18f83 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -1,4 +1,4 @@
-//===-- CPlusPlusNameParser.cpp ---------------------------------*- C++ -*-===//
+//===-- CPlusPlusNameParser.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -329,6 +329,37 @@ bool CPlusPlusNameParser::ConsumeOperator() {
}
const auto &token = Peek();
+
+ // When clang generates debug info it adds template parameters to names.
+ // Since clang doesn't add a space between the name and the template parameter
+ // in some cases we are not generating valid C++ names e.g.:
+ //
+ // operator<<A::B>
+ //
+ // In some of these cases we will not parse them correctly. This fixes the
+ // issue by detecting this case and inserting tok::less in place of
+ // tok::lessless and returning successfully that we consumed the operator.
+ if (token.getKind() == tok::lessless) {
+ // Make sure we have more tokens before attempting to look ahead one more.
+ if (m_next_token_index + 1 < m_tokens.size()) {
+ // Look ahead two tokens.
+ clang::Token n_token = m_tokens[m_next_token_index + 1];
+ // If we find ( or < then this is indeed operator<< no need for fix.
+ if (n_token.getKind() != tok::l_paren && n_token.getKind() != tok::less) {
+ clang::Token tmp_tok;
+ tmp_tok.startToken();
+ tmp_tok.setLength(1);
+ tmp_tok.setLocation(token.getLocation().getLocWithOffset(1));
+ tmp_tok.setKind(tok::less);
+
+ m_tokens[m_next_token_index] = tmp_tok;
+
+ start_position.Remove();
+ return true;
+ }
+ }
+ }
+
switch (token.getKind()) {
case tok::kw_new:
case tok::kw_delete: