1 //===-- CPlusPlusLanguage.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_CPlusPlusLanguage_h_
11 #define liblldb_CPlusPlusLanguage_h_
16 #include "llvm/ADT/StringRef.h"
18 #include "Plugins/Language/ClangCommon/ClangHighlighter.h"
19 #include "lldb/Target/Language.h"
20 #include "lldb/Utility/ConstString.h"
21 #include "lldb/lldb-private.h"
23 namespace lldb_private {
25 class CPlusPlusLanguage : public Language {
26 ClangHighlighter m_highlighter;
32 : m_full(), m_basename(), m_context(), m_arguments(), m_qualifiers(),
33 m_parsed(false), m_parse_error(false) {}
35 MethodName(const ConstString &s)
36 : m_full(s), m_basename(), m_context(), m_arguments(), m_qualifiers(),
37 m_parsed(false), m_parse_error(false) {}
49 const ConstString &GetFullName() const { return m_full; }
51 std::string GetScopeQualifiedName();
53 llvm::StringRef GetBasename();
55 llvm::StringRef GetContext();
57 llvm::StringRef GetArguments();
59 llvm::StringRef GetQualifiers();
63 bool TrySimplifiedParse();
65 ConstString m_full; // Full name:
66 // "lldb::SBTarget::GetBreakpointAtIndex(unsigned int)
68 llvm::StringRef m_basename; // Basename: "GetBreakpointAtIndex"
69 llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
70 llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
71 llvm::StringRef m_qualifiers; // Qualifiers: "const"
76 CPlusPlusLanguage() = default;
78 ~CPlusPlusLanguage() override = default;
80 lldb::LanguageType GetLanguageType() const override {
81 return lldb::eLanguageTypeC_plus_plus;
84 std::unique_ptr<TypeScavenger> GetTypeScavenger() override;
85 lldb::TypeCategoryImplSP GetFormatters() override;
87 HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override;
89 HardcodedFormatters::HardcodedSyntheticFinder
90 GetHardcodedSynthetics() override;
92 bool IsSourceFile(llvm::StringRef file_path) const override;
94 const Highlighter *GetHighlighter() const override { return &m_highlighter; }
96 //------------------------------------------------------------------
98 //------------------------------------------------------------------
99 static void Initialize();
101 static void Terminate();
103 static lldb_private::Language *CreateInstance(lldb::LanguageType language);
105 static lldb_private::ConstString GetPluginNameStatic();
107 static bool IsCPPMangledName(const char *name);
109 // Extract C++ context and identifier from a string using heuristic matching
111 // CPlusPlusLanguage::MethodName which has to have a fully qualified C++ name
112 // with parens and arguments.
113 // If the name is a lone C identifier (e.g. C) or a qualified C identifier
114 // (e.g. A::B::C) it will return true,
115 // and identifier will be the identifier (C and C respectively) and the
116 // context will be "" and "A::B" respectively.
117 // If the name fails the heuristic matching for a qualified or unqualified
118 // C/C++ identifier, then it will return false
119 // and identifier and context will be unchanged.
121 static bool ExtractContextAndIdentifier(const char *name,
122 llvm::StringRef &context,
123 llvm::StringRef &identifier);
125 // Given a mangled function name, calculates some alternative manglings since
126 // the compiler mangling may not line up with the symbol we are expecting
128 FindAlternateFunctionManglings(const ConstString mangled,
129 std::set<ConstString> &candidates);
131 //------------------------------------------------------------------
132 // PluginInterface protocol
133 //------------------------------------------------------------------
134 ConstString GetPluginName() override;
136 uint32_t GetPluginVersion() override;
139 } // namespace lldb_private
141 #endif // liblldb_CPlusPlusLanguage_h_