================
@@ -274,6 +323,81 @@ std::string DILParser::ParseNestedNameSpecifier() {
   }
 }
 
+// Parse a type_id.
+//
+//  type_id:
+//    type_specifier_seq [abstract_declarator]
+//
+//  type_specifier_seq:
+//    type_specifier [type_specifier]
+//
+//  type_specifier:
+//    ["::"] [nested_name_specifier] type_name // not handled for now!
+//    builtin_typename
+//
+std::optional<CompilerType> DILParser::ParseTypeId() {
+  CompilerType type;
+  // For now only allow builtin types -- will expand add to this later.
+  auto maybe_builtin_type = ParseBuiltinType();
+  if (maybe_builtin_type) {
+    type = *maybe_builtin_type;
+  } else
+    return {};
+
+  //
+  //  abstract_declarator:
+  //    ptr_operator [abstract_declarator]
+  //
+  std::vector<Token> ptr_operators;
+  while (CurToken().IsOneOf({Token::star, Token::amp})) {
+    Token tok = CurToken();
+    ptr_operators.push_back(std::move(tok));
+    m_dil_lexer.Advance();
+  }
+  type = ResolveTypeDeclarators(type, ptr_operators);
+
+  return type;
+}
+
+// Parse a built-in type
+//
+// builtin_typename:
+//   identifer_seq
+//
+//  identifier_seq
+//    identifer [identifier_seq]
+//
+// A built-in type can be a single identifier or a space-separated
+// list of identifiers (e.g. "short" or "long long").
+std::optional<CompilerType> DILParser::ParseBuiltinType() {
+  std::string type_name = "";
+  uint32_t save_token_idx = m_dil_lexer.GetCurrentTokenIdx();
+  bool first_word = true;
+  while (CurToken().GetKind() == Token::identifier) {
+    if (CurToken().GetSpelling() == "const" ||
+        CurToken().GetSpelling() == "volatile")
----------------
Michael137 wrote:

Should we be throwing away the CV-qualifiers here? I realise this is required 
for `GetBuiltinTypeByName`, but I'm not sure we should be dropping these behind 
the users back.

https://github.com/llvm/llvm-project/pull/165199
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to