================
@@ -400,6 +486,90 @@ std::optional<CompilerType> DILParser::ParseBuiltinType() {
return {};
}
+// Parse a type_specifier_seq.
+//
+// type_specifier_seq:
+// type_specifier [type_specifier_seq]
+//
+void DILParser::ParseTypeSpecifierSeq(std::string &type_name) {
+ while (true) {
+ bool type_specifier = ParseTypeSpecifier(type_name);
+ if (!type_specifier) {
+ break;
+ }
+ }
+}
+
+// Parse a type_specifier.
+//
+// type_specifier:
+// ["::"] [nested_name_specifier] type_name
+//
+// Returns TRUE if a type_specifier was successfully parsed at this location.
+//
+bool DILParser::ParseTypeSpecifier(std::string &user_type_name) {
+ // The type_specifier must be a user-defined type. Try parsing a
+ // simple_type_specifier.
+ {
+ // Try parsing optional global scope operator.
+ bool global_scope = false;
+ if (CurToken().Is(Token::coloncolon)) {
+ global_scope = true;
+ m_dil_lexer.Advance();
+ }
+
+ // uint32_t loc = CurToken().GetLocation();
+
+ // Try parsing optional nested_name_specifier.
+ auto nested_name_specifier = ParseNestedNameSpecifier();
+
+ // Try parsing required type_name.
+ auto type_name = ParseTypeName();
+
+ // If there is a type_name, then this is indeed a simple_type_specifier.
+ // Global and qualified (namespace/class) scopes can be empty, since
they're
+ // optional. In this case type_name is type we're looking for.
+ if (!type_name.empty()) {
+ // User-defined typenames can't be combined with builtin keywords.
+ user_type_name = llvm::formatv("{0}{1}{2}", global_scope ? "::" : "",
+ nested_name_specifier, type_name);
+ return true;
+ }
+ }
+
+ // No type_specifier was found here.
+ return false;
+}
+
+// Parse a type_name.
+//
+// type_name:
+// class_name
+// enum_name
+// typedef_name
+//
+// class_name
+// identifier
+//
+// enum_name
+// identifier
+//
+// typedef_name
+// identifier
+//
+std::string DILParser::ParseTypeName() {
+ // Typename always starts with an identifier.
+ if (CurToken().IsNot(Token::identifier)) {
+ return "";
----------------
Michael137 wrote:
`return std::nullopt`?
https://github.com/llvm/llvm-project/pull/175061
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits