[Lldb-commits] [lldb] [lldb][Fortran] Add support for Fortran base types (PR #212851)

Iasonas Karaprodromidis via lldb-commits lldb-commits at lists.llvm.org
Sat Aug 1 08:09:31 PDT 2026


https://github.com/Iasonaskrpr updated https://github.com/llvm/llvm-project/pull/212851

>From df22af8f68bbc694f603c11148b9a08b1fe9694d Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Sat, 9 May 2026 18:50:07 +0300
Subject: [PATCH 01/12] [lldb] Added boilerplate for new TypeSystem and
 DWARFASTParser

---
 .../Plugins/SymbolFile/DWARF/CMakeLists.txt   |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   2 +-
 .../DWARF/DWARFASTParserFortran.cpp           |  39 ++
 .../SymbolFile/DWARF/DWARFASTParserFortran.h  |  75 +++
 lldb/source/Plugins/TypeSystem/CMakeLists.txt |   1 +
 .../Plugins/TypeSystem/Fortran/CMakeLists.txt |  12 +
 .../TypeSystem/Fortran/TypeSystemFortran.cpp  |   0
 .../TypeSystem/Fortran/TypeSystemFortran.h    | 480 ++++++++++++++++++
 8 files changed, 611 insertions(+), 1 deletion(-)
 create mode 100644 lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
 create mode 100644 lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
 create mode 100644 lldb/source/Plugins/TypeSystem/Fortran/CMakeLists.txt
 create mode 100644 lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
 create mode 100644 lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index 3f7cf023ac21c..b198ec4e99b24 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -16,6 +16,7 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
   DIERef.cpp
   DWARFASTParser.cpp
   DWARFASTParserClang.cpp
+  DWARFASTParserFortran.cpp
   DWARFAttribute.cpp
   DWARFBaseDIE.cpp
   DWARFCompileUnit.cpp
@@ -57,7 +58,9 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
     lldbPluginObjCLanguage
     lldbPluginCPlusPlusLanguage
     lldbPluginExpressionParserClang
+    lldbPluginFortranLanguage
     lldbPluginTypeSystemClang
+    lldbPluginTypeSystemFortran
   CLANG_LIBS
     clangAST
     clangBasic
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 80f7becc1b24b..8f32874d788af 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -29,7 +29,7 @@ class SymbolFileDWARF;
 
 class DWARFASTParser {
 public:
-  enum class Kind { DWARFASTParserClang };
+  enum class Kind { DWARFASTParserClang, DWARFASTParserFortran };
   DWARFASTParser(Kind kind) : m_kind(kind) {}
 
   virtual ~DWARFASTParser() = default;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
new file mode 100644
index 0000000000000..0973f658f6b04
--- /dev/null
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
@@ -0,0 +1,39 @@
+//===-- DWARFASTParserFortran.cpp -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFASTParserFortran.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+DWARFASTParserFortran::DWARFASTParserFortran(
+    lldb_private::TypeSystemFortran m_ast)
+    : lldb_private::plugin::dwarf::DWARFASTParser(Kind::DWARFASTParserFortran),
+      m_ast(m_ast) {}
+
+DWARFASTParserFortran::~DWARFASTParserFortran() {}
+
+lldb::TypeSP DWARFASTParserFortran::ParseTypeFromDWARF(
+    const lldb_private::SymbolContext &sc,
+    const lldb_private::plugin::dwarf::DWARFDIE &die, bool *type_is_new_ptr) {
+  // TODO
+}
+
+lldb_private::Function *DWARFASTParserFortran::ParseFunctionFromDWARF(
+    lldb_private::CompileUnit &comp_unit,
+    const lldb_private::plugin::dwarf::DWARFDIE &die,
+    lldb_private::AddressRanges ranges) {
+  // TODO
+}
+
+bool DWARFASTParserFortran::CompleteTypeFromDWARF(
+    const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type,
+    const lldb_private::CompilerType &compiler_type) {
+  // TODO
+  return false;
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
new file mode 100644
index 0000000000000..6b26c798d190b
--- /dev/null
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
@@ -0,0 +1,75 @@
+//===-- DWARFASTParserFortran.h -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
+
+#include "DWARFASTParser.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/TypeSystem/Fortran/TypeSystemFortran.h"
+
+namespace lldb_private {
+class CompileUnit;
+class ExecutionContext;
+} // namespace lldb_private
+
+class DWARFASTParserFortran
+    : public lldb_private::plugin::dwarf::DWARFASTParser {
+public:
+  DWARFASTParserFortran(lldb_private::TypeSystemFortran m_ast);
+
+  ~DWARFASTParserFortran() override;
+
+  lldb::TypeSP
+  ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
+                     const lldb_private::plugin::dwarf::DWARFDIE &die,
+                     bool *type_is_new_ptr) override;
+
+  lldb_private::Function *
+  ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
+                         const lldb_private::plugin::dwarf::DWARFDIE &die,
+                         lldb_private::AddressRanges ranges) override;
+
+  bool CompleteTypeFromDWARF(
+      const lldb_private::plugin::dwarf::DWARFDIE &die,
+      lldb_private::Type *type,
+      const lldb_private::CompilerType &compiler_type) override;
+
+  lldb_private::ConstString ConstructDemangledNameFromDWARF(
+      const lldb_private::plugin::dwarf::DWARFDIE &die) override {
+    return lldb_private::ConstString();
+  }
+
+  lldb_private::CompilerDecl GetDeclForUIDFromDWARF(
+      const lldb_private::plugin::dwarf::DWARFDIE &die) override {
+    return lldb_private::CompilerDecl();
+  }
+
+  lldb_private::CompilerDeclContext GetDeclContextForUIDFromDWARF(
+      const lldb_private::plugin::dwarf::DWARFDIE &die) override {
+    return lldb_private::CompilerDeclContext();
+  }
+
+  lldb_private::CompilerDeclContext GetDeclContextContainingUIDFromDWARF(
+      const lldb_private::plugin::dwarf::DWARFDIE &die) override {
+    return lldb_private::CompilerDeclContext();
+  }
+
+  void EnsureAllDIEsInDeclContextHaveBeenParsed(
+      lldb_private::CompilerDeclContext decl_context) override {}
+
+  std::string GetDIEClassTemplateParams(
+      lldb_private::plugin::dwarf::DWARFDIE die) override {
+    return {};
+  }
+
+private:
+  lldb_private::TypeSystemFortran &m_ast;
+};
+
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
diff --git a/lldb/source/Plugins/TypeSystem/CMakeLists.txt b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
index 47e32ff176d8c..24431c14fca61 100644
--- a/lldb/source/Plugins/TypeSystem/CMakeLists.txt
+++ b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
@@ -3,3 +3,4 @@ set_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND TypeSystem)
 set_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES SymbolFile)
 
 add_subdirectory(Clang)
+add_subdirectory(Fortran)
\ No newline at end of file
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/CMakeLists.txt b/lldb/source/Plugins/TypeSystem/Fortran/CMakeLists.txt
new file mode 100644
index 0000000000000..c78b70d48eb31
--- /dev/null
+++ b/lldb/source/Plugins/TypeSystem/Fortran/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_library(lldbPluginTypeSystemFortran PLUGIN
+  TypeSystemFortran.cpp
+
+  LINK_COMPONENTS
+    Support
+  LINK_LIBS
+    lldbCore
+    lldbSymbol
+    lldbTarget
+    lldbUtility
+    lldbPluginSymbolFileDWARF
+)
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
new file mode 100644
index 0000000000000..be1844a16853c
--- /dev/null
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
@@ -0,0 +1,480 @@
+//===-- TypeSystemFortran.h -------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
+#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
+#include "lldb/Symbol/TypeSystem.h"
+#include "llvm/Support/ErrorHandling.h"
+namespace lldb_private {
+
+class TypeSystemFortran : public TypeSystem {
+
+  // llvm casting support
+  bool isA(const void *ClassID) const override { return ClassID == &ID; }
+  static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
+
+  TypeSystemFortran();
+  ~TypeSystemFortran();
+
+  // CompilerDecl functions
+  ConstString DeclGetName(void *opaque_decl) override { return ConstString(); }
+
+  CompilerType GetTypeForDecl(void *opaque_decl) override {
+    return CompilerType();
+  }
+
+  // CompilerDeclContext functions
+
+  ConstString DeclContextGetName(void *opaque_decl_ctx) override {
+    return ConstString();
+  }
+
+  ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override {
+    return ConstString();
+  }
+
+  bool DeclContextIsClassMethod(void *opaque_decl_ctx) override {
+    return false;
+  }
+
+  bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
+                                      void *other_opaque_decl_ctx) override {
+    return false;
+  }
+
+  lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override {
+    return lldb::LanguageType::eLanguageTypeUnknown;
+  }
+
+// Tests
+#ifndef NDEBUG
+  /// Verify the integrity of the type to catch CompilerTypes that mix
+  /// and match invalid TypeSystem/Opaque type pairs.
+  bool Verify(lldb::opaque_compiler_type_t type) { return false; };
+#endif
+
+  bool IsArrayType(lldb::opaque_compiler_type_t type,
+                   CompilerType *element_type, uint64_t *size,
+                   bool *is_incomplete) override {
+    return false;
+  };
+
+  bool IsAggregateType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsCharType(lldb::opaque_compiler_type_t type) override { return false; }
+
+  bool IsCompleteType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsDefined(lldb::opaque_compiler_type_t type) override { return false; }
+
+  bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsFunctionType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  size_t
+  GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+                                          const size_t index) override {
+    return CompilerType();
+  }
+
+  bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsMemberDataPointerType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+                          CompilerType *function_pointer_type_ptr) override {
+    return false;
+  }
+
+  bool IsIntegerType(lldb::opaque_compiler_type_t type,
+                     bool &is_signed) override {
+    return false;
+  };
+
+  bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+                             CompilerType *target_type, // Can pass NULL
+                             bool check_cplusplus, bool check_objc) override {
+    return false;
+  }
+
+  bool IsPointerType(lldb::opaque_compiler_type_t type,
+                     CompilerType *pointee_type) override {
+    return false;
+  }
+
+  bool IsScalarType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsVoidType(lldb::opaque_compiler_type_t type) override { return false; }
+
+  bool CanPassInRegisters(const CompilerType &type) override { return false; }
+
+  // TypeSystems can support more than one language
+  bool SupportsLanguage(lldb::LanguageType language) override {
+    if (language == lldb::LanguageType::eLanguageTypeFortran77 ||
+        language == lldb::LanguageType::eLanguageTypeFortran90 ||
+        language == lldb::LanguageType::eLanguageTypeFortran95 ||
+        language == lldb::LanguageType::eLanguageTypeFortran03 ||
+        language == lldb::LanguageType::eLanguageTypeFortran08 ||
+        language == lldb::LanguageType::eLanguageTypeFortran18) {
+      return true;
+    }
+    return false;
+  }
+
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
+
+  static llvm::StringRef GetPluginNameStatic() { return "fortran"; }
+
+  // Type Completion
+
+  bool GetCompleteType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  // AST related queries
+
+  uint32_t GetPointerByteSize() override { return 0; }
+
+  CompilerType GetPointerDiffType(bool is_signed) override {
+    return CompilerType();
+  }
+
+  unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  // Accessors
+
+  ConstString GetTypeName(lldb::opaque_compiler_type_t type,
+                          bool BaseOnly) override {
+    return ConstString();
+  }
+
+  ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override {
+    return ConstString();
+  }
+
+  uint32_t
+  GetTypeInfo(lldb::opaque_compiler_type_t type,
+              CompilerType *pointee_or_element_compiler_type) override {
+    return 0;
+  }
+
+  lldb::LanguageType
+  GetMinimumLanguage(lldb::opaque_compiler_type_t type) override {
+    return lldb::LanguageType::eLanguageTypeUnknown;
+  }
+
+  lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override {
+    return lldb::TypeClass::eTypeClassInvalid;
+  }
+
+  // Creating related types
+
+  CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+                                   ExecutionContextScope *exe_scope) override {
+    return CompilerType();
+  }
+
+  CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  // Returns -1 if this isn't a function of if the function doesn't have a
+  // prototype Returns a value >= 0 if there is a prototype.
+  int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override {
+    return -1;
+  }
+
+  CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+                                              size_t idx) override {
+    return CompilerType();
+  }
+
+  CompilerType
+  GetFunctionReturnType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  TypeMemberFunctionImpl
+  GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+                           size_t idx) override {
+    return TypeMemberFunctionImpl();
+  }
+
+  CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  // Exploring the type
+
+  const llvm::fltSemantics &
+  GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override {
+    return llvm::APFloatBase::Bogus();
+  }
+
+  llvm::Expected<uint64_t>
+  GetBitSize(lldb::opaque_compiler_type_t type,
+             ExecutionContextScope *exe_scope) override {
+    return 0;
+  }
+
+  lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override {
+    return lldb::eEncodingInvalid;
+  }
+
+  lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override {
+    return lldb::eFormatDefault;
+  }
+
+  llvm::Expected<uint32_t>
+  GetNumChildren(lldb::opaque_compiler_type_t type,
+                 bool omit_empty_base_classes,
+                 const ExecutionContext *exe_ctx) override {
+    return 0;
+  }
+
+  lldb::BasicType
+  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override {
+    return lldb::eBasicTypeUnsignedInt;
+  }
+
+  uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+                               std::string &name, uint64_t *bit_offset_ptr,
+                               uint32_t *bitfield_bit_size_ptr,
+                               bool *is_bitfield_ptr) override {
+    return CompilerType();
+  }
+
+  uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  uint32_t
+  GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+                                         size_t idx,
+                                         uint32_t *bit_offset_ptr) override {
+    return CompilerType();
+  }
+
+  CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+                                          size_t idx,
+                                          uint32_t *bit_offset_ptr) override {
+    return CompilerType();
+  }
+
+  llvm::Expected<CompilerType>
+  GetDereferencedType(lldb::opaque_compiler_type_t type,
+                      ExecutionContext *exe_ctx, std::string &deref_name,
+                      uint32_t &deref_byte_size, int32_t &deref_byte_offset,
+                      ValueObject *valobj, uint64_t &language_flags) override {
+    return CompilerType();
+  }
+
+  llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
+      lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+      bool transparent_pointers, bool omit_empty_base_classes,
+      bool ignore_array_bounds, std::string &child_name,
+      uint32_t &child_byte_size, int32_t &child_byte_offset,
+      uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+      bool &child_is_base_class, bool &child_is_deref_of_parent,
+      ValueObject *valobj, uint64_t &language_flags) override {
+    return CompilerType();
+  }
+
+  // Lookup a child given a name. This function will match base class names and
+  // member member names in "clang_type" only, not descendants.
+  llvm::Expected<uint32_t>
+  GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+                          llvm::StringRef name,
+                          bool omit_empty_base_classes) override {
+    return 0;
+  }
+
+  size_t
+  GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+                                llvm::StringRef name,
+                                bool omit_empty_base_classes,
+                                std::vector<uint32_t> &child_indexes) override {
+    return 0;
+  }
+
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override {
+  }
+#endif
+
+  bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s,
+                     lldb::Format format, const DataExtractor &data,
+                     lldb::offset_t data_offset, size_t data_byte_size,
+                     uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+                     ExecutionContextScope *exe_scope) override {
+    return false;
+  }
+
+  /// Dump the type to stdout.
+  void DumpTypeDescription(
+      lldb::opaque_compiler_type_t type,
+      lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) override {}
+
+  /// Print a description of the type to a stream. The exact implementation
+  /// varies, but the expectation is that eDescriptionLevelFull returns a
+  /// source-like representation of the type, whereas eDescriptionLevelVerbose
+  /// does a dump of the underlying AST if applicable.
+  void DumpTypeDescription(
+      lldb::opaque_compiler_type_t type, Stream &s,
+      lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) override {}
+
+  /// Dump a textual representation of the internal TypeSystem state to the
+  /// given stream.
+  ///
+  /// This should not modify the state of the TypeSystem if possible.
+  ///
+  /// \param[out] output Stream to dup the AST into.
+  /// \param[in] filter If empty, dump whole AST. If non-empty, will only
+  /// dump decls whose names contain \c filter.
+  /// \param[in] show_color If true, prints the AST color-highlighted.
+  void Dump(llvm::raw_ostream &output, llvm::StringRef filter,
+            bool show_color) override {}
+
+  /// This is used by swift.
+  bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  // TODO: Determine if these methods should move to TypeSystemClang.
+
+  bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+                                CompilerType *pointee_type) override {
+    return false;
+  }
+
+  unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override {
+    return 0;
+  }
+
+  std::optional<size_t>
+  GetTypeBitAlign(lldb::opaque_compiler_type_t type,
+                  ExecutionContextScope *exe_scope) override {
+    return 0;
+  }
+
+  CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override {
+    return CompilerType();
+  }
+
+  CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+                                                   size_t bit_size) override {
+    return CompilerType();
+  }
+
+  bool IsBeingDefined(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsConst(lldb::opaque_compiler_type_t type) override { return false; }
+
+  uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+                                  CompilerType *base_type_ptr) override {
+    return 0;
+  }
+
+  bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  bool IsTypedefType(lldb::opaque_compiler_type_t type) override {
+    return false;
+  }
+
+  // If the current object represents a typedef type, get the underlying type
+  CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  bool IsVectorType(lldb::opaque_compiler_type_t type,
+                    CompilerType *element_type, uint64_t *size) override {
+    return false;
+  }
+
+  CompilerType
+  GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+
+  CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override {
+    return CompilerType();
+  }
+  // TODO
+  bool IsReferenceType(lldb::opaque_compiler_type_t type,
+                       CompilerType *pointee_type, bool *is_rvalue) override {
+    return false;
+  }
+
+private:
+  // LLVM RTTI support
+  static char ID;
+};
+} // namespace lldb_private
+#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H

>From 21ff578224ae5c189aaa9a456948fc8f9dd2bf29 Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Sat, 9 May 2026 20:14:29 +0300
Subject: [PATCH 02/12] [lldb] Added Fortran language Plugin

---
 lldb/include/lldb/Target/Language.h           |  2 +
 lldb/source/Plugins/Language/CMakeLists.txt   |  1 +
 .../Plugins/Language/Fortran/CMakeLists.txt   | 12 ++++
 .../Language/Fortran/FortranLanguage.cpp      | 60 +++++++++++++++++++
 .../Language/Fortran/FortranLanguage.h        | 53 ++++++++++++++++
 lldb/source/Target/Language.cpp               | 14 +++++
 6 files changed, 142 insertions(+)
 create mode 100644 lldb/source/Plugins/Language/Fortran/CMakeLists.txt
 create mode 100644 lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp
 create mode 100644 lldb/source/Plugins/Language/Fortran/FortranLanguage.h

diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h
index bd3faf89658c9..5c7bdfcc628ce 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -443,6 +443,8 @@ class Language : public PluginInterface {
   /// Equivalent to \c LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus.
   static bool LanguageIsCFamily(lldb::LanguageType language);
 
+  static bool LanguageIsFortran(lldb::LanguageType language);
+
   static bool LanguageIsPascal(lldb::LanguageType language);
 
   // return the primary language, so if LanguageIsC(l), return eLanguageTypeC,
diff --git a/lldb/source/Plugins/Language/CMakeLists.txt b/lldb/source/Plugins/Language/CMakeLists.txt
index 6367ab916c8fb..5377734af2f8d 100644
--- a/lldb/source/Plugins/Language/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CMakeLists.txt
@@ -7,3 +7,4 @@ set_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES
 add_subdirectory(CPlusPlus)
 add_subdirectory(ObjC)
 add_subdirectory(ObjCPlusPlus)
+add_subdirectory(Fortran)
diff --git a/lldb/source/Plugins/Language/Fortran/CMakeLists.txt b/lldb/source/Plugins/Language/Fortran/CMakeLists.txt
new file mode 100644
index 0000000000000..7c5faa87aeaba
--- /dev/null
+++ b/lldb/source/Plugins/Language/Fortran/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_library(lldbPluginFortranLanguage PLUGIN
+  FortranLanguage.cpp
+
+  LINK_LIBS
+    lldbCore
+    lldbDataFormatters
+    lldbExpression
+    lldbHost
+    lldbSymbol
+    lldbTarget
+    lldbUtility
+)
\ No newline at end of file
diff --git a/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp b/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp
new file mode 100644
index 0000000000000..a7040ae337b17
--- /dev/null
+++ b/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp
@@ -0,0 +1,60 @@
+//===-- FortranLanguage.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/StringRef.h"
+
+#include "FortranLanguage.h"
+
+#include "lldb/Core/PluginManager.h"
+
+#include "Plugins/TypeSystem/Fortran/TypeSystemFortran.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+LLDB_PLUGIN_DEFINE(FortranLanguage)
+
+void FortranLanguage::Initialize() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(), "Fortran Language",
+                                CreateInstance);
+}
+
+void FortranLanguage::Terminate() {
+  PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+StringRef FortranLanguage::GetPluginNameStatic() {
+  static llvm::StringRef g_name("fortran");
+  return g_name;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+StringRef FortranLanguage::GetPluginName() { return GetPluginNameStatic(); }
+
+uint32_t FortranLanguage::GetPluginVersion() { return 1; }
+
+Language *FortranLanguage::CreateInstance(LanguageType language) {
+  // FIXME: Should Fortran 77 be supported???
+  if (Language::LanguageIsFortran(language)) {
+    return new FortranLanguage();
+  }
+  return nullptr;
+}
+
+bool FortranLanguage::IsSourceFile(StringRef file_path) const {
+  const auto suffixes = {".f90", ".f"};
+  for (auto suffix : suffixes) {
+    if (file_path.ends_with_insensitive(suffix))
+      return true;
+  }
+  return false;
+}
diff --git a/lldb/source/Plugins/Language/Fortran/FortranLanguage.h b/lldb/source/Plugins/Language/Fortran/FortranLanguage.h
new file mode 100644
index 0000000000000..1116564e96c7a
--- /dev/null
+++ b/lldb/source/Plugins/Language/Fortran/FortranLanguage.h
@@ -0,0 +1,53 @@
+//===-- FortranLanguage.h -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_FORTRAN_FORTRANLANGUAGE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_FORTRAN_FORTRANLANGUAGE_H
+#include "lldb/Target/Language.h"
+
+#include "llvm/ADT/StringRef.h"
+
+#include "lldb/Target/Language.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class FortranLanguage : public Language {
+public:
+  FortranLanguage() = default;
+
+  ~FortranLanguage() override = default;
+
+  lldb::LanguageType GetLanguageType() const override {
+    return lldb::eLanguageTypeFortran90;
+  }
+  //------------------------------------------------------------------
+  // Static Functions
+  //------------------------------------------------------------------
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+  static llvm::StringRef GetPluginNameStatic();
+
+  //------------------------------------------------------------------
+  // PluginInterface protocol
+  //------------------------------------------------------------------
+  llvm::StringRef GetPluginName() override;
+
+  uint32_t GetPluginVersion();
+
+  bool IsSourceFile(llvm::StringRef file_path) const override;
+};
+
+}; // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_FORTRAN_FORTRANLANGUAGE_H
\ No newline at end of file
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 077c403f4ea58..a4d6031b4b27d 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -396,6 +396,20 @@ bool Language::LanguageIsCFamily(LanguageType language) {
   }
 }
 
+bool Language::LanguageIsFortran(LanguageType language) {
+  switch (language) {
+  case eLanguageTypeFortran77:
+  case eLanguageTypeFortran90:
+  case eLanguageTypeFortran95:
+  case eLanguageTypeFortran03:
+  case eLanguageTypeFortran08:
+  case eLanguageTypeFortran18:
+    return true;
+  default:
+    return false;
+  }
+}
+
 bool Language::LanguageIsPascal(LanguageType language) {
   switch (language) {
   case eLanguageTypePascal83:

>From 386586dbecd885e22d2a729dd3d7d506b3491728 Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Thu, 14 May 2026 23:20:53 +0300
Subject: [PATCH 03/12] [lldb][Fortran] Added TypeSystemFortran to lldb-forward
 declarations

---
 lldb/include/lldb/lldb-forward.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index 67888f7d32ed1..9c6a11dd6d9b3 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -282,6 +282,7 @@ class TypeSummaryImpl;
 class TypeSummaryOptions;
 class TypeSystem;
 class TypeSystemClang;
+class TypeSystemFortran;
 class UUID;
 class UnixSignals;
 class Unwind;

>From 892418722a475697f0f7ef597806b758f4526fe0 Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Tue, 9 Jun 2026 15:11:19 +0300
Subject: [PATCH 04/12] [lldb][Fortran] Added plugin registration tests for
 Fortran

---
 lldb/unittests/Language/CMakeLists.txt        |  1 +
 .../unittests/Language/Fortran/CMakeLists.txt |  6 ++++
 .../Language/Fortran/FortranLanguageTest.cpp  | 36 +++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 lldb/unittests/Language/Fortran/CMakeLists.txt
 create mode 100644 lldb/unittests/Language/Fortran/FortranLanguageTest.cpp

diff --git a/lldb/unittests/Language/CMakeLists.txt b/lldb/unittests/Language/CMakeLists.txt
index a0bdc62af98c6..26710ff8896e2 100644
--- a/lldb/unittests/Language/CMakeLists.txt
+++ b/lldb/unittests/Language/CMakeLists.txt
@@ -1,3 +1,4 @@
 add_subdirectory(CPlusPlus)
 add_subdirectory(CLanguages)
 add_subdirectory(ObjC)
+add_subdirectory(Fortran)
diff --git a/lldb/unittests/Language/Fortran/CMakeLists.txt b/lldb/unittests/Language/Fortran/CMakeLists.txt
new file mode 100644
index 0000000000000..661b12ebf8950
--- /dev/null
+++ b/lldb/unittests/Language/Fortran/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_lldb_unittest(LanguageFortranLanguageTests
+  FortranLanguageTest.cpp
+
+  LINK_LIBS
+    lldbPluginFortranLanguage
+)
diff --git a/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp b/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp
new file mode 100644
index 0000000000000..0b5e9b9e43818
--- /dev/null
+++ b/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp
@@ -0,0 +1,36 @@
+//===-- FortranLanguagesTest.cpp ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/Language/Fortran/FortranLanguage.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+/// Returns the name of the LLDB plugin for the given language or an empty
+/// string if there is no fitting plugin.
+static llvm::StringRef GetPluginName(lldb::LanguageType language) {
+  Language *language_plugin = Language::FindPlugin(language);
+  if (language_plugin)
+    return language_plugin->GetPluginName();
+  return "";
+}
+
+TEST(FortranLanguage, LookupFortranLanguageByLanguageType) {
+  SubsystemRAII<FortranLanguage> langs;
+
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeFortran77), "fortran");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeFortran90), "fortran");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeFortran95), "fortran");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeFortran03), "fortran");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeFortran08), "fortran");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeFortran18), "fortran");
+}

>From 1666320b8e3032a38af239462583020a8ff1210f Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Sat, 27 Jun 2026 15:27:54 +0300
Subject: [PATCH 05/12] [lldb][Fortran] Finalized lldb plugin skeleton

---
 .../DWARF/DWARFASTParserFortran.cpp           |  7 +-
 .../SymbolFile/DWARF/DWARFASTParserFortran.h  |  2 +-
 .../TypeSystem/Fortran/TypeSystemFortran.cpp  | 87 +++++++++++++++++++
 .../TypeSystem/Fortran/TypeSystemFortran.h    | 38 ++++----
 4 files changed, 114 insertions(+), 20 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
index 0973f658f6b04..2b9267f26612f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
@@ -12,7 +12,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 DWARFASTParserFortran::DWARFASTParserFortran(
-    lldb_private::TypeSystemFortran m_ast)
+    lldb_private::TypeSystemFortran &m_ast)
     : lldb_private::plugin::dwarf::DWARFASTParser(Kind::DWARFASTParserFortran),
       m_ast(m_ast) {}
 
@@ -21,19 +21,18 @@ DWARFASTParserFortran::~DWARFASTParserFortran() {}
 lldb::TypeSP DWARFASTParserFortran::ParseTypeFromDWARF(
     const lldb_private::SymbolContext &sc,
     const lldb_private::plugin::dwarf::DWARFDIE &die, bool *type_is_new_ptr) {
-  // TODO
+  return lldb::TypeSP();
 }
 
 lldb_private::Function *DWARFASTParserFortran::ParseFunctionFromDWARF(
     lldb_private::CompileUnit &comp_unit,
     const lldb_private::plugin::dwarf::DWARFDIE &die,
     lldb_private::AddressRanges ranges) {
-  // TODO
+  return nullptr;
 }
 
 bool DWARFASTParserFortran::CompleteTypeFromDWARF(
     const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type,
     const lldb_private::CompilerType &compiler_type) {
-  // TODO
   return false;
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
index 6b26c798d190b..a688a8e810118 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
@@ -21,7 +21,7 @@ class ExecutionContext;
 class DWARFASTParserFortran
     : public lldb_private::plugin::dwarf::DWARFASTParser {
 public:
-  DWARFASTParserFortran(lldb_private::TypeSystemFortran m_ast);
+  DWARFASTParserFortran(lldb_private::TypeSystemFortran &m_ast);
 
   ~DWARFASTParserFortran() override;
 
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
index e69de29bb2d1d..7b6da8a77009d 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
@@ -0,0 +1,87 @@
+//===-- TypeSystemFortran.cpp -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "TypeSystemFortran.h"
+
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Target/Target.h"
+
+#include "Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace llvm;
+using namespace lldb_private::plugin::dwarf;
+
+LLDB_PLUGIN_DEFINE(TypeSystemFortran)
+
+/// Used to determine if TypeSystem supports the language passed in
+/// CreateInstance
+static bool IsLanguageSupported(lldb::LanguageType language) {
+  if (language == lldb::LanguageType::eLanguageTypeFortran77 ||
+      language == lldb::LanguageType::eLanguageTypeFortran90 ||
+      language == lldb::LanguageType::eLanguageTypeFortran95 ||
+      language == lldb::LanguageType::eLanguageTypeFortran03 ||
+      language == lldb::LanguageType::eLanguageTypeFortran08 ||
+      language == lldb::LanguageType::eLanguageTypeFortran18)
+    return true;
+
+  return false;
+}
+
+char TypeSystemFortran::ID;
+
+TypeSystemFortran::~TypeSystemFortran() = default;
+TypeSystemFortran::TypeSystemFortran() = default;
+
+void TypeSystemFortran::Initialize() {
+  PluginManager::RegisterPlugin(
+      GetPluginNameStatic(), "fortran AST context plug-in", CreateInstance,
+      GetSupportedLanguagesForTypes(), GetSupportedLanguagesForExpressions());
+}
+
+void TypeSystemFortran::Terminate() {
+  PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+plugin::dwarf::DWARFASTParser *TypeSystemFortran::GetDWARFParser() {
+  if (!m_dwarf_ast_parser_up)
+    m_dwarf_ast_parser_up = std::make_unique<DWARFASTParserFortran>(*this);
+  return m_dwarf_ast_parser_up.get();
+}
+
+// TODO: Process Target and architecture for pointers and Expression Evaluation,
+// if module and target have different typesystems like clang, we would have to
+// account for that here
+lldb::TypeSystemSP
+TypeSystemFortran::CreateInstance(lldb::LanguageType language, Module *module,
+                                  Target *target) {
+  if (IsLanguageSupported(language)) {
+    return std::make_shared<TypeSystemFortran>();
+  }
+  return TypeSystemSP();
+}
+
+LanguageSet TypeSystemFortran::GetSupportedLanguagesForTypes() {
+  LanguageSet languages;
+  languages.Insert(eLanguageTypeFortran77);
+  languages.Insert(eLanguageTypeFortran90);
+  languages.Insert(eLanguageTypeFortran95);
+  languages.Insert(eLanguageTypeFortran03);
+  languages.Insert(eLanguageTypeFortran08);
+  languages.Insert(eLanguageTypeFortran18);
+  return languages;
+}
+
+LanguageSet TypeSystemFortran::GetSupportedLanguagesForExpressions() {
+  return GetSupportedLanguagesForTypes();
+}
+
+bool TypeSystemFortran::SupportsLanguage(lldb::LanguageType language) {
+  return IsLanguageSupported(language);
+}
\ No newline at end of file
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
index be1844a16853c..bf68cea4553c2 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
@@ -13,7 +13,10 @@
 namespace lldb_private {
 
 class TypeSystemFortran : public TypeSystem {
+  // LLVM RTTI support
+  static char ID;
 
+public:
   // llvm casting support
   bool isA(const void *ClassID) const override { return ClassID == &ID; }
   static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
@@ -21,6 +24,19 @@ class TypeSystemFortran : public TypeSystem {
   TypeSystemFortran();
   ~TypeSystemFortran();
 
+  static void Initialize();
+
+  static void Terminate();
+
+  plugin::dwarf::DWARFASTParser *GetDWARFParser() override;
+
+  static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+                                           Module *module, Target *target);
+
+  static LanguageSet GetSupportedLanguagesForTypes();
+
+  static LanguageSet GetSupportedLanguagesForExpressions();
+
   // CompilerDecl functions
   ConstString DeclGetName(void *opaque_decl) override { return ConstString(); }
 
@@ -55,7 +71,7 @@ class TypeSystemFortran : public TypeSystem {
 #ifndef NDEBUG
   /// Verify the integrity of the type to catch CompilerTypes that mix
   /// and match invalid TypeSystem/Opaque type pairs.
-  bool Verify(lldb::opaque_compiler_type_t type) { return false; };
+  bool Verify(lldb::opaque_compiler_type_t type) override { return false; };
 #endif
 
   bool IsArrayType(lldb::opaque_compiler_type_t type,
@@ -140,17 +156,7 @@ class TypeSystemFortran : public TypeSystem {
   bool CanPassInRegisters(const CompilerType &type) override { return false; }
 
   // TypeSystems can support more than one language
-  bool SupportsLanguage(lldb::LanguageType language) override {
-    if (language == lldb::LanguageType::eLanguageTypeFortran77 ||
-        language == lldb::LanguageType::eLanguageTypeFortran90 ||
-        language == lldb::LanguageType::eLanguageTypeFortran95 ||
-        language == lldb::LanguageType::eLanguageTypeFortran03 ||
-        language == lldb::LanguageType::eLanguageTypeFortran08 ||
-        language == lldb::LanguageType::eLanguageTypeFortran18) {
-      return true;
-    }
-    return false;
-  }
+  bool SupportsLanguage(lldb::LanguageType language) override;
 
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
@@ -201,7 +207,7 @@ class TypeSystemFortran : public TypeSystem {
 
   lldb::LanguageType
   GetMinimumLanguage(lldb::opaque_compiler_type_t type) override {
-    return lldb::LanguageType::eLanguageTypeUnknown;
+    return lldb::LanguageType::eLanguageTypeFortran90;
   }
 
   lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override {
@@ -473,8 +479,10 @@ class TypeSystemFortran : public TypeSystem {
   }
 
 private:
-  // LLVM RTTI support
-  static char ID;
+  std::unique_ptr<plugin::dwarf::DWARFASTParser> m_dwarf_ast_parser_up;
+
+  TypeSystemFortran(const TypeSystemFortran &) = delete;
+  const TypeSystemFortran &operator=(const TypeSystemFortran &) = delete;
 };
 } // namespace lldb_private
 #endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H

>From 74bab4e14b23e5478924e6af29cae7a647b5f6bc Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Sat, 27 Jun 2026 15:50:19 +0300
Subject: [PATCH 06/12] [lldb][Fortran] Added variable guard to Fortran Plugin

---
 lldb/source/Plugins/Language/CMakeLists.txt      |  4 +++-
 .../Plugins/SymbolFile/DWARF/CMakeLists.txt      | 16 +++++++++++++---
 lldb/source/Plugins/TypeSystem/CMakeLists.txt    |  5 ++++-
 lldb/unittests/Language/CMakeLists.txt           |  4 +++-
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/Language/CMakeLists.txt b/lldb/source/Plugins/Language/CMakeLists.txt
index 5377734af2f8d..bdecd0bf2a6a3 100644
--- a/lldb/source/Plugins/Language/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CMakeLists.txt
@@ -7,4 +7,6 @@ set_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES
 add_subdirectory(CPlusPlus)
 add_subdirectory(ObjC)
 add_subdirectory(ObjCPlusPlus)
-add_subdirectory(Fortran)
+if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)
+  add_subdirectory(Fortran)
+endif()
\ No newline at end of file
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index b198ec4e99b24..027cad4cbdd6f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -16,7 +16,6 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
   DIERef.cpp
   DWARFASTParser.cpp
   DWARFASTParserClang.cpp
-  DWARFASTParserFortran.cpp
   DWARFAttribute.cpp
   DWARFBaseDIE.cpp
   DWARFCompileUnit.cpp
@@ -58,9 +57,7 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
     lldbPluginObjCLanguage
     lldbPluginCPlusPlusLanguage
     lldbPluginExpressionParserClang
-    lldbPluginFortranLanguage
     lldbPluginTypeSystemClang
-    lldbPluginTypeSystemFortran
   CLANG_LIBS
     clangAST
     clangBasic
@@ -69,3 +66,16 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
 add_dependencies(lldbPluginSymbolFileDWARF
   LLDBPluginSymbolFileDWARFPropertiesGen
   LLDBPluginSymbolFileDWARFPropertiesEnumGen)
+
+if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)
+
+  target_sources(lldbPluginSymbolFileDWARF PRIVATE 
+    DWARFASTParserFortran.cpp
+  )
+
+  target_link_libraries(lldbPluginSymbolFileDWARF PRIVATE 
+    lldbPluginFortranLanguage 
+    lldbPluginTypeSystemFortran
+  )
+
+endif()
diff --git a/lldb/source/Plugins/TypeSystem/CMakeLists.txt b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
index 24431c14fca61..3128f207eaee3 100644
--- a/lldb/source/Plugins/TypeSystem/CMakeLists.txt
+++ b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
@@ -3,4 +3,7 @@ set_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND TypeSystem)
 set_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES SymbolFile)
 
 add_subdirectory(Clang)
-add_subdirectory(Fortran)
\ No newline at end of file
+
+if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)
+  add_subdirectory(Fortran)
+endif()
\ No newline at end of file
diff --git a/lldb/unittests/Language/CMakeLists.txt b/lldb/unittests/Language/CMakeLists.txt
index 26710ff8896e2..d23dec58328be 100644
--- a/lldb/unittests/Language/CMakeLists.txt
+++ b/lldb/unittests/Language/CMakeLists.txt
@@ -1,4 +1,6 @@
 add_subdirectory(CPlusPlus)
 add_subdirectory(CLanguages)
 add_subdirectory(ObjC)
-add_subdirectory(Fortran)
+if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)  
+  add_subdirectory(Fortran)
+endif()
\ No newline at end of file

>From 5f7cd48bdbb0cadd25fda3166a1405498bcbd4c2 Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Sun, 28 Jun 2026 19:02:22 +0300
Subject: [PATCH 07/12] [lldb][Fortran] Added FindFlang module and updated
 CMAKE flag guarding for Fortran support in lldb

---
 lldb/cmake/modules/FindFlang.cmake              | 17 +++++++++++++++++
 lldb/cmake/modules/LLDBConfig.cmake             |  1 +
 lldb/source/Plugins/Language/CMakeLists.txt     |  2 +-
 .../Plugins/SymbolFile/DWARF/CMakeLists.txt     | 16 +++++++++-------
 lldb/source/Plugins/TypeSystem/CMakeLists.txt   |  2 +-
 lldb/unittests/Language/CMakeLists.txt          |  2 +-
 6 files changed, 30 insertions(+), 10 deletions(-)
 create mode 100644 lldb/cmake/modules/FindFlang.cmake

diff --git a/lldb/cmake/modules/FindFlang.cmake b/lldb/cmake/modules/FindFlang.cmake
new file mode 100644
index 0000000000000..f71d42c5fb586
--- /dev/null
+++ b/lldb/cmake/modules/FindFlang.cmake
@@ -0,0 +1,17 @@
+# FindFlang.cmake
+
+include(FindPackageHandleStandardArgs)
+
+# If Flang and lldb are in-tree then the libraries will already be available, otherwise look for specific directories
+if(TARGET flangFrontEnd)
+  set(Flang_FOUND TRUE)
+else()
+  find_package(Flang QUIET CONFIG HINTS ${Flang_DIR} ${LLVM_DIR}/../flang)
+endif()
+
+find_package_handle_standard_args(Flang
+  FOUND_VAR
+    Flang_FOUND
+  REQUIRED_VARS
+    Flang_FOUND
+)
\ No newline at end of file
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index e086aaf5d3632..82ad8b19ebb79 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -64,6 +64,7 @@ add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" L
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION ${LLDB_LIBXML2_VERSION})
 add_optional_dependency(LLDB_ENABLE_TREESITTER "Enable Tree-sitter syntax highlighting" TreeSitter TREESITTER_FOUND)
+add_optional_dependency(LLDB_ENABLE_FORTRAN "Enable Fortran support in lldb" Flang Flang_FOUND)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
diff --git a/lldb/source/Plugins/Language/CMakeLists.txt b/lldb/source/Plugins/Language/CMakeLists.txt
index bdecd0bf2a6a3..2dd89b5207a57 100644
--- a/lldb/source/Plugins/Language/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CMakeLists.txt
@@ -7,6 +7,6 @@ set_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES
 add_subdirectory(CPlusPlus)
 add_subdirectory(ObjC)
 add_subdirectory(ObjCPlusPlus)
-if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)
+if(LLDB_ENABLE_FORTRAN)
   add_subdirectory(Fortran)
 endif()
\ No newline at end of file
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index 027cad4cbdd6f..dcaf1c2df2b19 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -10,6 +10,13 @@ lldb_tablegen(SymbolFileDWARFProperties.json -dump-json
   SOURCE SymbolFileDWARFProperties.td
   TARGET LLDBPluginSymbolFileDWARFPropertiesJsonGen)
 
+set(LLVM_OPTIONAL_SOURCES DWARFASTParserFortran.cpp)
+
+set(FORTRAN_DWARF_SOURCES "")
+if(LLDB_ENABLE_FORTRAN)
+  set(FORTRAN_DWARF_SOURCES DWARFASTParserFortran.cpp)
+endif()
+
 add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
   AppleDWARFIndex.cpp
   DebugNamesDWARFIndex.cpp
@@ -41,6 +48,7 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
   SymbolFileDWARFDebugMap.cpp
   SymbolFileWasm.cpp
   UniqueDWARFASTType.cpp
+  ${FORTRAN_DWARF_SOURCES}
 
   LINK_COMPONENTS
     DebugInfoDWARF
@@ -67,15 +75,9 @@ add_dependencies(lldbPluginSymbolFileDWARF
   LLDBPluginSymbolFileDWARFPropertiesGen
   LLDBPluginSymbolFileDWARFPropertiesEnumGen)
 
-if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)
-
-  target_sources(lldbPluginSymbolFileDWARF PRIVATE 
-    DWARFASTParserFortran.cpp
-  )
-
+if(LLDB_ENABLE_FORTRAN)
   target_link_libraries(lldbPluginSymbolFileDWARF PRIVATE 
     lldbPluginFortranLanguage 
     lldbPluginTypeSystemFortran
   )
-
 endif()
diff --git a/lldb/source/Plugins/TypeSystem/CMakeLists.txt b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
index 3128f207eaee3..7342c5a8af639 100644
--- a/lldb/source/Plugins/TypeSystem/CMakeLists.txt
+++ b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
@@ -4,6 +4,6 @@ set_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES SymbolFile)
 
 add_subdirectory(Clang)
 
-if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)
+if(LLDB_ENABLE_FORTRAN)
   add_subdirectory(Fortran)
 endif()
\ No newline at end of file
diff --git a/lldb/unittests/Language/CMakeLists.txt b/lldb/unittests/Language/CMakeLists.txt
index d23dec58328be..db43874757bc3 100644
--- a/lldb/unittests/Language/CMakeLists.txt
+++ b/lldb/unittests/Language/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_subdirectory(CPlusPlus)
 add_subdirectory(CLanguages)
 add_subdirectory(ObjC)
-if("flang" IN_LIST LLVM_ENABLE_PROJECTS OR "all" IN_LIST LLVM_ENABLE_PROJECTS)  
+if(LLDB_ENABLE_FORTRAN)  
   add_subdirectory(Fortran)
 endif()
\ No newline at end of file

>From 122a48c1885b7eb18f0a8eb3ea000ac2eca8731c Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Fri, 17 Jul 2026 19:02:42 +0300
Subject: [PATCH 08/12] [lldb] Removed CMake changes

---
 lldb/cmake/modules/FindFlang.cmake  | 17 -----------------
 lldb/cmake/modules/LLDBConfig.cmake |  1 -
 2 files changed, 18 deletions(-)
 delete mode 100644 lldb/cmake/modules/FindFlang.cmake

diff --git a/lldb/cmake/modules/FindFlang.cmake b/lldb/cmake/modules/FindFlang.cmake
deleted file mode 100644
index f71d42c5fb586..0000000000000
--- a/lldb/cmake/modules/FindFlang.cmake
+++ /dev/null
@@ -1,17 +0,0 @@
-# FindFlang.cmake
-
-include(FindPackageHandleStandardArgs)
-
-# If Flang and lldb are in-tree then the libraries will already be available, otherwise look for specific directories
-if(TARGET flangFrontEnd)
-  set(Flang_FOUND TRUE)
-else()
-  find_package(Flang QUIET CONFIG HINTS ${Flang_DIR} ${LLVM_DIR}/../flang)
-endif()
-
-find_package_handle_standard_args(Flang
-  FOUND_VAR
-    Flang_FOUND
-  REQUIRED_VARS
-    Flang_FOUND
-)
\ No newline at end of file
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 82ad8b19ebb79..e086aaf5d3632 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -64,7 +64,6 @@ add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" L
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION ${LLDB_LIBXML2_VERSION})
 add_optional_dependency(LLDB_ENABLE_TREESITTER "Enable Tree-sitter syntax highlighting" TreeSitter TREESITTER_FOUND)
-add_optional_dependency(LLDB_ENABLE_FORTRAN "Enable Fortran support in lldb" Flang Flang_FOUND)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)

>From 3c81c8db819d1d9b7e7dc5a0cb2145db02bfa48d Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Fri, 17 Jul 2026 19:36:51 +0300
Subject: [PATCH 09/12] [lldb][Fortran] Removed TODO comments and updated file
 headers

---
 .../Plugins/Language/Fortran/FortranLanguage.cpp       | 10 +++++++---
 lldb/source/Plugins/Language/Fortran/FortranLanguage.h |  7 ++++++-
 .../Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp |  7 ++++++-
 .../Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h   |  7 ++++++-
 .../Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp   | 10 ++++++----
 .../Plugins/TypeSystem/Fortran/TypeSystemFortran.h     |  9 +++++++--
 .../unittests/Language/Fortran/FortranLanguageTest.cpp |  7 ++++++-
 7 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp b/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp
index a7040ae337b17..240b7cbab07a6 100644
--- a/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp
+++ b/lldb/source/Plugins/Language/Fortran/FortranLanguage.cpp
@@ -1,10 +1,15 @@
-//===-- FortranLanguage.cpp -----------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements the Fortran language Plugin.
+///
+//===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/StringRef.h"
 
@@ -43,7 +48,6 @@ StringRef FortranLanguage::GetPluginName() { return GetPluginNameStatic(); }
 uint32_t FortranLanguage::GetPluginVersion() { return 1; }
 
 Language *FortranLanguage::CreateInstance(LanguageType language) {
-  // FIXME: Should Fortran 77 be supported???
   if (Language::LanguageIsFortran(language)) {
     return new FortranLanguage();
   }
@@ -51,7 +55,7 @@ Language *FortranLanguage::CreateInstance(LanguageType language) {
 }
 
 bool FortranLanguage::IsSourceFile(StringRef file_path) const {
-  const auto suffixes = {".f90", ".f"};
+  const auto suffixes = {".f90", ".f", ".f95", ".f03", ".f08", ".f18"};
   for (auto suffix : suffixes) {
     if (file_path.ends_with_insensitive(suffix))
       return true;
diff --git a/lldb/source/Plugins/Language/Fortran/FortranLanguage.h b/lldb/source/Plugins/Language/Fortran/FortranLanguage.h
index 1116564e96c7a..2bd616f347b78 100644
--- a/lldb/source/Plugins/Language/Fortran/FortranLanguage.h
+++ b/lldb/source/Plugins/Language/Fortran/FortranLanguage.h
@@ -1,10 +1,15 @@
-//===-- FortranLanguage.h -------------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file defines the Fortran language Plugin.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_FORTRAN_FORTRANLANGUAGE_H
 #define LLDB_SOURCE_PLUGINS_LANGUAGE_FORTRAN_FORTRANLANGUAGE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
index 2b9267f26612f..1179e0e004600 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
@@ -1,10 +1,15 @@
-//===-- DWARFASTParserFortran.cpp -----------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements the DWARF AST Parser for the Fortran language.
+///
+//===----------------------------------------------------------------------===//
 
 #include "DWARFASTParserFortran.h"
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
index a688a8e810118..b0410be2ba89e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
@@ -1,10 +1,15 @@
-//===-- DWARFASTParserFortran.h -------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file defines the DWARF AST Parser for the Fortran language.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
index 7b6da8a77009d..2fe29a81c7520 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
@@ -1,10 +1,15 @@
-//===-- TypeSystemFortran.cpp -----------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements the Fortran type system.
+///
+//===----------------------------------------------------------------------===//
 #include "TypeSystemFortran.h"
 
 #include "lldb/Core/PluginManager.h"
@@ -55,9 +60,6 @@ plugin::dwarf::DWARFASTParser *TypeSystemFortran::GetDWARFParser() {
   return m_dwarf_ast_parser_up.get();
 }
 
-// TODO: Process Target and architecture for pointers and Expression Evaluation,
-// if module and target have different typesystems like clang, we would have to
-// account for that here
 lldb::TypeSystemSP
 TypeSystemFortran::CreateInstance(lldb::LanguageType language, Module *module,
                                   Target *target) {
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
index bf68cea4553c2..0c7e1f4c18c6c 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
@@ -1,10 +1,15 @@
-//===-- TypeSystemFortran.h -------------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the definition of the Fortran Type System.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
 #define LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
@@ -472,7 +477,7 @@ class TypeSystemFortran : public TypeSystem {
   CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override {
     return CompilerType();
   }
-  // TODO
+
   bool IsReferenceType(lldb::opaque_compiler_type_t type,
                        CompilerType *pointee_type, bool *is_rvalue) override {
     return false;
diff --git a/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp b/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp
index 0b5e9b9e43818..5b81544539785 100644
--- a/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp
+++ b/lldb/unittests/Language/Fortran/FortranLanguageTest.cpp
@@ -1,10 +1,15 @@
-//===-- FortranLanguagesTest.cpp ------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file tests the Fortran Plugin features.
+///
+//===----------------------------------------------------------------------===//
 
 #include "Plugins/Language/Fortran/FortranLanguage.h"
 #include "TestingSupport/SubsystemRAII.h"

>From 9674d58723f9a5c4680ca0396e6634e397c6dfb8 Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Wed, 29 Jul 2026 21:12:18 +0300
Subject: [PATCH 10/12] [lldb][Fortran] Added support for Integer, logical,
 Real and complex types

---
 .../DWARF/DWARFASTParserFortran.cpp           | 195 +++++++++-
 .../SymbolFile/DWARF/DWARFASTParserFortran.h  |  11 +-
 .../Plugins/TypeSystem/Fortran/FortranTypes.h |  91 +++++
 .../TypeSystem/Fortran/TypeSystemFortran.cpp  | 339 +++++++++++++++++-
 .../TypeSystem/Fortran/TypeSystemFortran.h    | 148 ++++----
 lldb/test/API/lang/fortran/complex/Makefile   |   3 +
 .../fortran/complex/TestFortranComplex.py     |  33 ++
 .../test/API/lang/fortran/complex/complex.f90 |  13 +
 .../API/lang/fortran/frame-variable/Makefile  |   3 +
 .../TestFortranFrameVariable.py               |  27 ++
 .../API/lang/fortran/frame-variable/frame.f90 |  17 +
 lldb/test/API/lang/fortran/integer/Makefile   |   3 +
 .../fortran/integer/TestFortranIntegers.py    |  45 +++
 .../API/lang/fortran/integer/integers.f90     |  16 +
 lldb/test/API/lang/fortran/lit.local.cfg      |   2 +
 lldb/test/API/lang/fortran/logical/Makefile   |   3 +
 .../fortran/logical/TestFortranLogical.py     |  45 +++
 .../test/API/lang/fortran/logical/logical.f90 |  17 +
 lldb/test/API/lang/fortran/real/Makefile      |   3 +
 .../API/lang/fortran/real/TestFortranReal.py  |  33 ++
 lldb/test/API/lang/fortran/real/real.f90      |  12 +
 21 files changed, 963 insertions(+), 96 deletions(-)
 create mode 100644 lldb/source/Plugins/TypeSystem/Fortran/FortranTypes.h
 create mode 100644 lldb/test/API/lang/fortran/complex/Makefile
 create mode 100644 lldb/test/API/lang/fortran/complex/TestFortranComplex.py
 create mode 100644 lldb/test/API/lang/fortran/complex/complex.f90
 create mode 100644 lldb/test/API/lang/fortran/frame-variable/Makefile
 create mode 100644 lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py
 create mode 100644 lldb/test/API/lang/fortran/frame-variable/frame.f90
 create mode 100644 lldb/test/API/lang/fortran/integer/Makefile
 create mode 100644 lldb/test/API/lang/fortran/integer/TestFortranIntegers.py
 create mode 100644 lldb/test/API/lang/fortran/integer/integers.f90
 create mode 100644 lldb/test/API/lang/fortran/lit.local.cfg
 create mode 100644 lldb/test/API/lang/fortran/logical/Makefile
 create mode 100644 lldb/test/API/lang/fortran/logical/TestFortranLogical.py
 create mode 100644 lldb/test/API/lang/fortran/logical/logical.f90
 create mode 100644 lldb/test/API/lang/fortran/real/Makefile
 create mode 100644 lldb/test/API/lang/fortran/real/TestFortranReal.py
 create mode 100644 lldb/test/API/lang/fortran/real/real.f90

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
index 1179e0e004600..dffa5e5af5a99 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.cpp
@@ -13,31 +13,196 @@
 
 #include "DWARFASTParserFortran.h"
 
+#include "DWARFDIE.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFDeclContext.h"
+#include "DWARFDefines.h"
+#include "LogChannelDWARF.h"
+#include "Plugins/TypeSystem/Fortran/FortranTypes.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDebugMap.h"
+#include "UniqueDWARFASTType.h"
+
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/ValueObject/ValueObject.h"
+
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::plugin::dwarf;
+using namespace llvm::dwarf;
+using namespace lldb_private::plugin::fortran;
 
-DWARFASTParserFortran::DWARFASTParserFortran(
-    lldb_private::TypeSystemFortran &m_ast)
-    : lldb_private::plugin::dwarf::DWARFASTParser(Kind::DWARFASTParserFortran),
-      m_ast(m_ast) {}
+DWARFASTParserFortran::DWARFASTParserFortran(TypeSystemFortran &ast)
+    : DWARFASTParser(Kind::DWARFASTParserFortran), m_ast(ast) {}
 
 DWARFASTParserFortran::~DWARFASTParserFortran() {}
 
-lldb::TypeSP DWARFASTParserFortran::ParseTypeFromDWARF(
-    const lldb_private::SymbolContext &sc,
-    const lldb_private::plugin::dwarf::DWARFDIE &die, bool *type_is_new_ptr) {
-  return lldb::TypeSP();
+// TODO: Add more logging here there is not enough
+lldb::TypeSP DWARFASTParserFortran::ParseTypeFromDWARF(const SymbolContext &sc,
+                                                       const DWARFDIE &die,
+                                                       bool *type_is_new_ptr) {
+  TypeSP type_sp;
+  if (type_is_new_ptr)
+    *type_is_new_ptr = false;
+
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+
+  if (die) {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    if (log) {
+      dwarf->GetObjectFile()->GetModule()->LogMessage(
+          log,
+          "DWARFASTParserFortran::ParseTypeFromDWARF (die = 0x%8.8x) %s name"
+          "= "
+          "'%s')",
+          die.GetOffset(), plugin::dwarf::DW_TAG_value_to_name(die.Tag()),
+          die.GetName());
+    }
+    Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
+    if (!type_ptr) {
+      if (type_is_new_ptr)
+        *type_is_new_ptr = true;
+
+      const dw_tag_t tag = die.Tag();
+      ConstString type_name;
+      const char *type_name_cstr = nullptr;
+      CompilerType compiler_type;
+      DWARFAttributes attributes;
+      DWARFFormValue form_value;
+      Declaration decl;
+      uint32_t encoding = 0;
+      switch (tag) {
+      case DW_TAG_base_type: {
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+        attributes = die.GetAttributes();
+        uint64_t bit_size = 0;
+        for (size_t idx = 0; idx < attributes.Size(); idx++) {
+          if (attributes.ExtractFormValueAtIndex(idx, form_value)) {
+            switch (attributes.AttributeAtIndex(idx)) {
+            case DW_AT_name:
+              type_name_cstr = form_value.AsCString();
+              if (type_name_cstr &&
+                  type_name_cstr[0]) { // Check for null AND empty string
+                type_name.SetString(llvm::StringRef(type_name_cstr).upper());
+              } else {
+                type_name.SetCString("UNKNOWN_FORTRAN_TYPE");
+              }
+              break;
+            case DW_AT_encoding:
+              encoding = form_value.Unsigned();
+              break;
+            case DW_AT_byte_size:
+              bit_size = form_value.Unsigned() * 8;
+              break;
+            case DW_AT_bit_size:
+              bit_size = form_value.Unsigned();
+              break;
+            default:
+              break;
+            }
+          }
+        }
+        compiler_type = m_ast.CreateType(encoding, bit_size, type_name);
+        type_sp =
+            dwarf->MakeType(die.GetID(), type_name, (bit_size + 7) / 8, nullptr,
+                            LLDB_INVALID_UID, Type::eEncodingIsUID, decl,
+                            compiler_type, Type::ResolveState::Full);
+      } break;
+      case DW_TAG_subprogram:
+      case DW_TAG_subroutine_type: {
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+        attributes = die.GetAttributes();
+        size_t num_attr = attributes.Size();
+        for (size_t i = 0; i < num_attr; ++i) {
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attributes.AttributeAtIndex(i)) {
+            case DW_AT_name:
+              type_name_cstr = form_value.AsCString();
+              if (type_name_cstr &&
+                  type_name_cstr[0]) { // Check for null AND empty string
+                type_name.SetString(llvm::StringRef(type_name_cstr).upper());
+              } else {
+                type_name.SetCString("UNKNOWN_FORTRAN_FUNCTION");
+              }
+              break;
+            default:
+              break;
+            }
+          }
+        }
+        llvm::SmallVector<CompilerType, 4> function_params_types;
+        // TODO: Parse Parameters here, for now this is not supported
+        compiler_type =
+            m_ast.GetOrCreateFortranFunction(type_name, function_params_types);
+        type_sp = dwarf->MakeType(die.GetID(), type_name, 0, nullptr,
+                                  LLDB_INVALID_UID, Type::eEncodingIsUID, decl,
+                                  compiler_type, Type::ResolveState::Full);
+      } break;
+      default:
+        break;
+      }
+      if (type_sp.get()) {
+        // TODO: Here calculate the variable scope
+        dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+      }
+    } else if (type_ptr != DIE_IS_BEING_PARSED) {
+      type_sp = type_ptr->shared_from_this();
+    }
+  }
+  return type_sp;
 }
 
 lldb_private::Function *DWARFASTParserFortran::ParseFunctionFromDWARF(
     lldb_private::CompileUnit &comp_unit,
     const lldb_private::plugin::dwarf::DWARFDIE &die,
     lldb_private::AddressRanges ranges) {
-  return nullptr;
-}
+  if (die.Tag() != DW_TAG_subprogram)
+    return nullptr;
+  llvm::DWARFAddressRangesVector unused_func_ranges;
+  const char *name = nullptr;
+  const char *mangled = nullptr;
+  std::optional<int> decl_file = 0;
+  std::optional<int> decl_line = 0;
+  std::optional<int> decl_column = 0;
+  std::optional<int> call_file = 0;
+  std::optional<int> call_line = 0;
+  std::optional<int> call_column = 0;
+  DWARFExpressionList frame_base;
+  if (die.GetDIENamesAndRanges(name, mangled, unused_func_ranges, decl_file,
+                               decl_line, decl_column, call_file, call_line,
+                               call_column, &frame_base)) {
+    Mangled func_name;
+    // Mangled doesn't know how to demangle fortran names
+    if (mangled)
+      func_name.SetMangledName(ConstString(mangled));
+    if (name)
+      func_name.SetDemangledName(ConstString(name));
 
-bool DWARFASTParserFortran::CompleteTypeFromDWARF(
-    const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type,
-    const lldb_private::CompilerType &compiler_type) {
-  return false;
-}
+    FunctionSP func_sp;
+
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    // Supply the type _only_ if it has already been parsed
+    Type *func_type = dwarf->GetDIEToType().lookup(die.GetDIE());
+
+    assert(func_type == nullptr || func_type != DIE_IS_BEING_PARSED);
+
+    const user_id_t func_user_id = die.GetID();
+
+    Address func_addr = ranges[0].GetBaseAddress();
+
+    func_sp =
+        std::make_shared<Function>(&comp_unit,
+                                   func_user_id, // UserID is the DIE offset
+                                   func_user_id, func_name, func_type,
+                                   std::move(func_addr), std::move(ranges));
+
+    if (func_sp.get() != nullptr) {
+      if (frame_base.IsValid())
+        func_sp->GetFrameBaseExpression() = frame_base;
+      comp_unit.AddFunction(func_sp);
+      return func_sp.get();
+    }
+  }
+  return nullptr;
+}
\ No newline at end of file
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
index b0410be2ba89e..61c273a6b5a2d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h
@@ -21,12 +21,13 @@
 namespace lldb_private {
 class CompileUnit;
 class ExecutionContext;
+class TypeSystemFortran;
 } // namespace lldb_private
 
 class DWARFASTParserFortran
     : public lldb_private::plugin::dwarf::DWARFASTParser {
 public:
-  DWARFASTParserFortran(lldb_private::TypeSystemFortran &m_ast);
+  DWARFASTParserFortran(lldb_private::TypeSystemFortran &ast);
 
   ~DWARFASTParserFortran() override;
 
@@ -43,8 +44,12 @@ class DWARFASTParserFortran
   bool CompleteTypeFromDWARF(
       const lldb_private::plugin::dwarf::DWARFDIE &die,
       lldb_private::Type *type,
-      const lldb_private::CompilerType &compiler_type) override;
+      const lldb_private::CompilerType &compiler_type) override {
+    return false;
+  }
 
+  // TODO: The following functions are left intentionally blank and will be
+  // populated in a future patch
   lldb_private::ConstString ConstructDemangledNameFromDWARF(
       const lldb_private::plugin::dwarf::DWARFDIE &die) override {
     return lldb_private::ConstString();
@@ -77,4 +82,4 @@ class DWARFASTParserFortran
   lldb_private::TypeSystemFortran &m_ast;
 };
 
-#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERFORTRAN_H
\ No newline at end of file
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/FortranTypes.h b/lldb/source/Plugins/TypeSystem/Fortran/FortranTypes.h
new file mode 100644
index 0000000000000..b2598d206f3a7
--- /dev/null
+++ b/lldb/source/Plugins/TypeSystem/Fortran/FortranTypes.h
@@ -0,0 +1,91 @@
+//===-- FortranTypes.h ------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_FORTRANTYPES_H
+#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_FORTRANTYPES_H
+
+#include "lldb/Expression/DWARFExpressionList.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/ConstString.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace lldb_private {
+namespace plugin {
+namespace fortran {
+
+/// A simplified internal representation of a Fortran basic type.
+/// Types that need more information than this will inherit from this class.
+class FortranType : public llvm::FoldingSetNode {
+public:
+  enum TypeKind {
+    KIND_INTEGER,
+    KIND_LOGICAL,
+    KIND_REAL,
+    KIND_COMPLEX,
+    KIND_FUNCTION,
+    KIND_UNKNOWN
+  };
+  FortranType(int32_t kind, uint64_t bitsize, const ConstString &name)
+      : m_kind(kind), m_bitsize(bitsize), m_type_name(name) {}
+  virtual ~FortranType() = default;
+  int GetKind() const { return m_kind; }
+  uint64_t GetBitSize() const { return m_bitsize; }
+  ConstString GetName() const { return m_type_name; }
+
+  void Profile(llvm::FoldingSetNodeID &ID) const {
+    Profile(ID, m_kind, m_bitsize);
+  }
+
+  static void Profile(llvm::FoldingSetNodeID &ID, int32_t kind,
+                      uint64_t bitsize) {
+    ID.AddInteger(kind);
+    ID.AddInteger(bitsize);
+  }
+
+private:
+  int32_t m_kind;
+  uint64_t m_bitsize;
+  ConstString m_type_name;
+};
+
+/// We represent Functions as types to satisfy lldb's requirement for everything
+/// to be a type.
+class FortranFunction : public FortranType {
+public:
+  FortranFunction(ConstString func_name,
+                  const llvm::SmallVectorImpl<CompilerType> &parameters)
+      : FortranType(FortranType::KIND_FUNCTION, 0, func_name) {
+    m_parameters.assign(parameters.begin(), parameters.end());
+  }
+  llvm::ArrayRef<CompilerType> GetParameters() const { return m_parameters; }
+  size_t GetNumberOfParameters() const { return m_parameters.size(); }
+
+  void Profile(llvm::FoldingSetNodeID &id) const {
+    Profile(id, GetName(), m_parameters);
+  }
+
+  static void Profile(llvm::FoldingSetNodeID &id, ConstString func_name,
+                      llvm::ArrayRef<CompilerType> parameters) {
+    id.AddString(func_name.GetStringRef());
+    id.AddInteger(parameters.size());
+
+    for (const auto &param : parameters)
+      id.AddPointer(param.GetOpaqueQualType());
+  }
+
+private:
+  llvm::SmallVector<CompilerType, 4> m_parameters;
+};
+} // namespace fortran
+} // namespace plugin
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_FORTRANTYPES_H
\ No newline at end of file
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
index 2fe29a81c7520..4dcf16e21cda0 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
@@ -11,34 +11,69 @@
 ///
 //===----------------------------------------------------------------------===//
 #include "TypeSystemFortran.h"
+#include "FortranTypes.h"
 
+#include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBLog.h"
+
+#include "llvm/Support/raw_ostream.h"
 
 #include "Plugins/SymbolFile/DWARF/DWARFASTParserFortran.h"
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm;
+using namespace lldb_private::plugin::fortran;
 using namespace lldb_private::plugin::dwarf;
 
 LLDB_PLUGIN_DEFINE(TypeSystemFortran)
 
 /// Used to determine if TypeSystem supports the language passed in
 /// CreateInstance
-static bool IsLanguageSupported(lldb::LanguageType language) {
-  if (language == lldb::LanguageType::eLanguageTypeFortran77 ||
-      language == lldb::LanguageType::eLanguageTypeFortran90 ||
-      language == lldb::LanguageType::eLanguageTypeFortran95 ||
-      language == lldb::LanguageType::eLanguageTypeFortran03 ||
-      language == lldb::LanguageType::eLanguageTypeFortran08 ||
-      language == lldb::LanguageType::eLanguageTypeFortran18)
+static bool IsLanguageSupported(LanguageType language) {
+  if (language == LanguageType::eLanguageTypeFortran77 ||
+      language == LanguageType::eLanguageTypeFortran90 ||
+      language == LanguageType::eLanguageTypeFortran95 ||
+      language == LanguageType::eLanguageTypeFortran03 ||
+      language == LanguageType::eLanguageTypeFortran08 ||
+      language == LanguageType::eLanguageTypeFortran18)
     return true;
 
   return false;
 }
 
+/// Unlike C/C++, Fortran formats COMPLEX numbers as a parenthesised tuple
+/// (real, imaginary).
+static bool DumpComplex(Stream &s, const lldb_private::DataExtractor &data,
+                        lldb::offset_t &offset, size_t data_byte_size) {
+  if (sizeof(float) * 2 == data_byte_size) {
+    float f32_1 = data.GetFloat(&offset);
+    float f32_2 = data.GetFloat(&offset);
+
+    s.Printf("(%g, %g)", f32_1, f32_2);
+    return true;
+  } else if (sizeof(double) * 2 == data_byte_size) {
+    double d64_1 = data.GetDouble(&offset);
+    double d64_2 = data.GetDouble(&offset);
+
+    s.Printf("(%lg, %lg)", d64_1, d64_2);
+    return true;
+  } else if (sizeof(long double) * 2 == data_byte_size) {
+    long double ld64_1 = data.GetLongDouble(&offset);
+    long double ld64_2 = data.GetLongDouble(&offset);
+    s.Printf("(%Lg, %Lg)", ld64_1, ld64_2);
+    return true;
+  } else {
+    s.Printf("error: unsupported byte size (%" PRIu64
+             ") for complex float format",
+             (uint64_t)data_byte_size);
+    return false;
+  }
+}
+
 char TypeSystemFortran::ID;
 
 TypeSystemFortran::~TypeSystemFortran() = default;
@@ -60,11 +95,23 @@ plugin::dwarf::DWARFASTParser *TypeSystemFortran::GetDWARFParser() {
   return m_dwarf_ast_parser_up.get();
 }
 
-lldb::TypeSystemSP
-TypeSystemFortran::CreateInstance(lldb::LanguageType language, Module *module,
-                                  Target *target) {
+// TODO: Process Target and architecture for pointers and Expression Evaluation,
+// if module and target have different typesystems like clang, we would have to
+// account for that here.
+TypeSystemSP TypeSystemFortran::CreateInstance(LanguageType language,
+                                               Module *module, Target *target) {
+
   if (IsLanguageSupported(language)) {
-    return std::make_shared<TypeSystemFortran>();
+    auto type_system_sp = std::make_shared<TypeSystemFortran>();
+
+    // Get the byte order from the target or module and store it
+    if (target) {
+      type_system_sp->SetByteOrder(target->GetArchitecture().GetByteOrder());
+    } else if (module) {
+      type_system_sp->SetByteOrder(module->GetArchitecture().GetByteOrder());
+    }
+
+    return type_system_sp;
   }
   return TypeSystemSP();
 }
@@ -80,10 +127,276 @@ LanguageSet TypeSystemFortran::GetSupportedLanguagesForTypes() {
   return languages;
 }
 
+// FIXME: Currently returns all Fortran languages to satisfy plugin
+// requirements, but expression evaluation is not yet implemented.
 LanguageSet TypeSystemFortran::GetSupportedLanguagesForExpressions() {
-  return GetSupportedLanguagesForTypes();
+  LanguageSet languages;
+  languages.Insert(eLanguageTypeFortran77);
+  languages.Insert(eLanguageTypeFortran90);
+  languages.Insert(eLanguageTypeFortran95);
+  languages.Insert(eLanguageTypeFortran03);
+  languages.Insert(eLanguageTypeFortran08);
+  languages.Insert(eLanguageTypeFortran18);
+  return languages;
 }
 
 bool TypeSystemFortran::SupportsLanguage(lldb::LanguageType language) {
-  return IsLanguageSupported(language);
+  if (language == lldb::LanguageType::eLanguageTypeFortran77 ||
+      language == lldb::LanguageType::eLanguageTypeFortran90 ||
+      language == lldb::LanguageType::eLanguageTypeFortran95 ||
+      language == lldb::LanguageType::eLanguageTypeFortran03 ||
+      language == lldb::LanguageType::eLanguageTypeFortran08 ||
+      language == lldb::LanguageType::eLanguageTypeFortran18) {
+    return true;
+  }
+  return false;
+}
+
+CompilerType TypeSystemFortran::GetOrCreateFortranType(int kind,
+                                                       uint64_t bitsize,
+                                                       ConstString name) {
+  llvm::FoldingSetNodeID id;
+  FortranType::Profile(id, kind, bitsize);
+  void *insert_pos = nullptr;
+  FortranType *fortran_type = m_basic_types.FindNodeOrInsertPos(id, insert_pos);
+  if (fortran_type)
+    return CompilerType(weak_from_this(), (void *)fortran_type);
+  auto new_type_up = std::make_unique<FortranType>(kind, bitsize, name);
+  fortran_type = new_type_up.get();
+
+  m_types.push_back(std::move(new_type_up));
+  m_basic_types.InsertNode(fortran_type, insert_pos);
+  return CompilerType(weak_from_this(), (void *)fortran_type);
+}
+
+CompilerType TypeSystemFortran::GetOrCreateFortranFunction(
+    ConstString name, const SmallVectorImpl<CompilerType> &parameters) {
+  llvm::FoldingSetNodeID id;
+  FortranFunction::Profile(id, name, parameters);
+  void *insert_pos = nullptr;
+  FortranFunction *fortran_function =
+      m_functions.FindNodeOrInsertPos(id, insert_pos);
+  if (fortran_function)
+    return CompilerType(weak_from_this(), (void *)fortran_function);
+  auto new_type_up = std::make_unique<FortranFunction>(name, parameters);
+  fortran_function = new_type_up.get();
+
+  m_functions.InsertNode(fortran_function, insert_pos);
+  m_types.push_back(std::move(new_type_up));
+
+  return CompilerType(weak_from_this(), (void *)fortran_function);
+}
+
+CompilerType TypeSystemFortran::CreateType(uint32_t kind, uint64_t bitsize,
+                                           ConstString name) {
+  int underlying_kind;
+  switch (kind) {
+  case dwarf::DW_ATE_boolean:
+    if (bitsize == 32)
+      name.SetCString("LOGICAL");
+    underlying_kind = FortranType::KIND_LOGICAL;
+    break;
+  case dwarf::DW_ATE_float:
+    if (bitsize == 32)
+      name.SetCString("REAL");
+    underlying_kind = FortranType::KIND_REAL;
+    break;
+  case dwarf::DW_ATE_signed:
+    if (bitsize == 32)
+      name.SetCString("INTEGER");
+    underlying_kind = FortranType::KIND_INTEGER;
+    break;
+  case dwarf::DW_ATE_complex_float:
+    if (bitsize == 64)
+      name.SetCString("COMPLEX");
+    underlying_kind = FortranType::KIND_COMPLEX;
+    break;
+  default:
+    return CompilerType();
+  }
+  return GetOrCreateFortranType(underlying_kind, bitsize, name);
+}
+
+ConstString TypeSystemFortran::GetTypeName(opaque_compiler_type_t type,
+                                           bool BaseOnly) {
+  if (!type)
+    return ConstString();
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  switch (fortran_type->GetKind()) {
+  case FortranType::KIND_INTEGER:
+  case FortranType::KIND_LOGICAL:
+  case FortranType::KIND_REAL:
+  case FortranType::KIND_COMPLEX:
+    return fortran_type->GetName();
+  default:
+    return ConstString("Unsupported");
+  }
+}
+
+CompilerType TypeSystemFortran::GetBasicTypeFromAST(BasicType basic_type) {
+  switch (basic_type) {
+  case eBasicTypeInt:
+    return GetOrCreateFortranType(FortranType::KIND_INTEGER, 32,
+                                  ConstString("INTEGER"));
+  case eBasicTypeFloat:
+    return GetOrCreateFortranType(FortranType::KIND_REAL, 32,
+                                  ConstString("REAL"));
+  case eBasicTypeDouble:
+    return GetOrCreateFortranType(FortranType::KIND_REAL, 64,
+                                  ConstString("REAL(KIND=8)"));
+  case eBasicTypeBool:
+    return GetOrCreateFortranType(FortranType::KIND_LOGICAL, 32,
+                                  ConstString("LOGICAL"));
+  case eBasicTypeFloatComplex:
+    return GetOrCreateFortranType(FortranType::KIND_COMPLEX, 64,
+                                  ConstString("COMPLEX"));
+  case eBasicTypeDoubleComplex:
+    return GetOrCreateFortranType(FortranType::KIND_COMPLEX, 128,
+                                  ConstString("COMPLEX(KIND=8)"));
+  case eBasicTypeLongDoubleComplex:
+    return GetOrCreateFortranType(FortranType::KIND_COMPLEX, 256,
+                                  ConstString("COMPLEX(KIND=16)"));
+  default:
+    return CompilerType();
+  }
+}
+
+CompilerType
+TypeSystemFortran::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
+                                                       size_t bit_size) {
+  switch (encoding) {
+  case eEncodingSint:
+    return GetOrCreateFortranType(FortranType::KIND_INTEGER, bit_size,
+                                  ConstString("INTEGER"));
+  case eEncodingIEEE754:
+    return GetOrCreateFortranType(FortranType::KIND_REAL, bit_size,
+                                  ConstString("REAL"));
+  default:
+    return CompilerType();
+  }
+}
+
+uint32_t
+TypeSystemFortran::GetTypeInfo(opaque_compiler_type_t type,
+                               CompilerType *pointee_or_element_compiler_type) {
+  if (!type)
+    return 0;
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
+  int type_kind = fortran_type->GetKind();
+  switch (type_kind) {
+  case FortranType::KIND_REAL:
+  case FortranType::KIND_INTEGER:
+  case FortranType::KIND_LOGICAL:
+    builtin_type_flags |= eTypeIsScalar;
+    if (type_kind == FortranType::KIND_INTEGER)
+      builtin_type_flags |= eTypeIsInteger | eTypeIsSigned;
+    if (type_kind == FortranType::KIND_REAL)
+      builtin_type_flags |= eTypeIsFloat;
+    break;
+  case FortranType::KIND_COMPLEX:
+    builtin_type_flags |= eTypeIsComplex;
+    break;
+  default:
+    break;
+  }
+  return builtin_type_flags;
+}
+
+Expected<uint64_t>
+TypeSystemFortran::GetBitSize(opaque_compiler_type_t type,
+                              ExecutionContextScope *exe_scope) {
+  if (!type)
+    return 0;
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  return fortran_type->GetBitSize();
+}
+
+Encoding TypeSystemFortran::GetEncoding(opaque_compiler_type_t type) {
+  if (!type)
+    return eEncodingInvalid;
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  switch (fortran_type->GetKind()) {
+  case FortranType::KIND_COMPLEX:
+  case FortranType::KIND_REAL:
+    return eEncodingIEEE754;
+  case FortranType::KIND_INTEGER:
+    return eEncodingSint;
+  case FortranType::KIND_LOGICAL:
+    return eEncodingUint;
+  default:
+    return eEncodingInvalid;
+  }
+}
+
+Format TypeSystemFortran::GetFormat(opaque_compiler_type_t type) {
+  if (!type)
+    return eFormatDefault;
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  switch (fortran_type->GetKind()) {
+  case FortranType::KIND_INTEGER:
+    return eFormatDecimal;
+  case FortranType::KIND_REAL:
+    return eFormatFloat;
+  case FortranType::KIND_LOGICAL:
+    return eFormatBoolean;
+  case FortranType::KIND_COMPLEX:
+    return eFormatComplex;
+  default:
+    return eFormatDefault;
+  }
+}
+
+bool TypeSystemFortran::IsIntegerType(opaque_compiler_type_t type,
+                                      bool &is_signed) {
+  if (!type)
+    return false;
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  if (fortran_type->GetKind() == FortranType::KIND_INTEGER) {
+    is_signed = true;
+    return true;
+  }
+  return false;
+}
+
+bool TypeSystemFortran::IsFloatingPointType(opaque_compiler_type_t type) {
+  int kind = static_cast<FortranType *>(type)->GetKind();
+  if (kind == FortranType::KIND_REAL)
+    return true;
+  return false;
+}
+
+bool TypeSystemFortran::DumpTypeValue(
+    lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format,
+    const DataExtractor &data, lldb::offset_t data_offset,
+    size_t data_byte_size, uint32_t bitfield_bit_size,
+    uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) {
+  if (!type)
+    return false;
+
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  int type_kind = fortran_type->GetKind();
+  DataExtractor format_data;
+  switch (type_kind) {
+  case FortranType::KIND_INTEGER:
+  case FortranType::KIND_REAL:
+  case FortranType::KIND_LOGICAL:
+    format_data.SetData(data, 0, data.GetByteSize());
+    format_data.SetAddressByteSize(data.GetAddressByteSize());
+    format_data.SetByteOrder(m_byte_order);
+    return DumpDataExtractor(format_data, &s, data_offset, format,
+                             data_byte_size, 1 /*item_count*/, UINT32_MAX,
+                             LLDB_INVALID_ADDRESS, bitfield_bit_size,
+                             bitfield_bit_offset, exe_scope);
+  case FortranType::KIND_COMPLEX:
+    // For Complex we print the value exactly how Fortran prints it
+    format_data.SetData(data, 0, data.GetByteSize());
+    format_data.SetAddressByteSize(data.GetAddressByteSize());
+    format_data.SetByteOrder(m_byte_order);
+    return DumpComplex(s, data, data_offset, data_byte_size);
+  default:
+    Host::SystemLog(lldb::eSeverityError,
+                    "Error: DumpTypeValue not handled yet.\n");
+    return false;
+  }
 }
\ No newline at end of file
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
index 0c7e1f4c18c6c..33699addfdded 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
@@ -14,9 +14,24 @@
 #ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
 #define LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
 #include "lldb/Symbol/TypeSystem.h"
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/ErrorHandling.h"
+
 namespace lldb_private {
 
+namespace plugin {
+namespace fortran {
+class FortranType;
+class FortranFunction;
+} // namespace fortran
+} // namespace plugin
+
+/// A TypeSystem implementation for the Fortran language.
+///
+/// This plugin provides LLDB with the ability to understand Fortran types
+/// parsed from debug information (DWARF).
 class TypeSystemFortran : public TypeSystem {
   // LLVM RTTI support
   static char ID;
@@ -38,10 +53,18 @@ class TypeSystemFortran : public TypeSystem {
   static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
                                            Module *module, Target *target);
 
+  CompilerType CreateType(uint32_t kind, uint64_t bitsize, ConstString name);
+
   static LanguageSet GetSupportedLanguagesForTypes();
 
   static LanguageSet GetSupportedLanguagesForExpressions();
 
+  bool SupportsLanguage(lldb::LanguageType language) override;
+
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
+
+  static llvm::StringRef GetPluginNameStatic() { return "fortran"; }
+
   // CompilerDecl functions
   ConstString DeclGetName(void *opaque_decl) override { return ConstString(); }
 
@@ -76,14 +99,15 @@ class TypeSystemFortran : public TypeSystem {
 #ifndef NDEBUG
   /// Verify the integrity of the type to catch CompilerTypes that mix
   /// and match invalid TypeSystem/Opaque type pairs.
-  bool Verify(lldb::opaque_compiler_type_t type) override { return false; };
+  bool Verify(lldb::opaque_compiler_type_t type) override { return true; }
 #endif
 
+  // Type Classification
   bool IsArrayType(lldb::opaque_compiler_type_t type,
                    CompilerType *element_type, uint64_t *size,
                    bool *is_incomplete) override {
     return false;
-  };
+  }
 
   bool IsAggregateType(lldb::opaque_compiler_type_t type) override {
     return false;
@@ -92,15 +116,15 @@ class TypeSystemFortran : public TypeSystem {
   bool IsCharType(lldb::opaque_compiler_type_t type) override { return false; }
 
   bool IsCompleteType(lldb::opaque_compiler_type_t type) override {
-    return false;
+    return true;
   }
 
-  bool IsDefined(lldb::opaque_compiler_type_t type) override { return false; }
-
-  bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override {
-    return false;
+  bool IsDefined(lldb::opaque_compiler_type_t type) override {
+    return type != nullptr;
   }
 
+  bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override;
+
   bool IsFunctionType(lldb::opaque_compiler_type_t type) override {
     return false;
   }
@@ -133,9 +157,7 @@ class TypeSystemFortran : public TypeSystem {
   }
 
   bool IsIntegerType(lldb::opaque_compiler_type_t type,
-                     bool &is_signed) override {
-    return false;
-  };
+                     bool &is_signed) override;
 
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override {
     return false;
@@ -152,30 +174,21 @@ class TypeSystemFortran : public TypeSystem {
     return false;
   }
 
-  bool IsScalarType(lldb::opaque_compiler_type_t type) override {
-    return false;
-  }
+  bool IsScalarType(lldb::opaque_compiler_type_t type) override { return true; }
 
   bool IsVoidType(lldb::opaque_compiler_type_t type) override { return false; }
 
   bool CanPassInRegisters(const CompilerType &type) override { return false; }
 
-  // TypeSystems can support more than one language
-  bool SupportsLanguage(lldb::LanguageType language) override;
-
-  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
-
-  static llvm::StringRef GetPluginNameStatic() { return "fortran"; }
-
-  // Type Completion
-
+  // Type Completion, all basic types are complete
   bool GetCompleteType(lldb::opaque_compiler_type_t type) override {
-    return false;
+    return true;
   }
 
   // AST related queries
 
-  uint32_t GetPointerByteSize() override { return 0; }
+  // FIXME: This is temporary for now
+  uint32_t GetPointerByteSize() override { return 8; }
 
   CompilerType GetPointerDiffType(bool is_signed) override {
     return CompilerType();
@@ -194,21 +207,15 @@ class TypeSystemFortran : public TypeSystem {
   }
 
   // Accessors
-
   ConstString GetTypeName(lldb::opaque_compiler_type_t type,
-                          bool BaseOnly) override {
-    return ConstString();
-  }
+                          bool BaseOnly) override;
 
   ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override {
-    return ConstString();
+    return GetTypeName(type, false);
   }
 
-  uint32_t
-  GetTypeInfo(lldb::opaque_compiler_type_t type,
-              CompilerType *pointee_or_element_compiler_type) override {
-    return 0;
-  }
+  uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
+                       CompilerType *pointee_or_element_compiler_type) override;
 
   lldb::LanguageType
   GetMinimumLanguage(lldb::opaque_compiler_type_t type) override {
@@ -216,9 +223,18 @@ class TypeSystemFortran : public TypeSystem {
   }
 
   lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override {
-    return lldb::TypeClass::eTypeClassInvalid;
+    if (!type)
+      return lldb::eTypeClassInvalid;
+
+    return lldb::eTypeClassBuiltin;
   }
 
+  CompilerType GetOrCreateFortranType(int kind, uint64_t bitsize,
+                                      ConstString name);
+
+  CompilerType GetOrCreateFortranFunction(
+      ConstString name, const llvm::SmallVectorImpl<CompilerType> &parameters);
+
   // Creating related types
 
   CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
@@ -226,13 +242,16 @@ class TypeSystemFortran : public TypeSystem {
     return CompilerType();
   }
 
+  //
   CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override {
-    return CompilerType();
+    if (!type)
+      return CompilerType();
+    return CompilerType(weak_from_this(), type);
   }
 
   CompilerType
   GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override {
-    return CompilerType();
+    return CompilerType(weak_from_this(), type);
   }
 
   // Returns -1 if this isn't a function of if the function doesn't have a
@@ -269,6 +288,10 @@ class TypeSystemFortran : public TypeSystem {
     return CompilerType();
   }
 
+  void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+  lldb::ByteOrder GetByteOrder() { return m_byte_order; }
+
   // Exploring the type
 
   const llvm::fltSemantics &
@@ -278,17 +301,11 @@ class TypeSystemFortran : public TypeSystem {
 
   llvm::Expected<uint64_t>
   GetBitSize(lldb::opaque_compiler_type_t type,
-             ExecutionContextScope *exe_scope) override {
-    return 0;
-  }
+             ExecutionContextScope *exe_scope) override;
 
-  lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override {
-    return lldb::eEncodingInvalid;
-  }
+  lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override;
 
-  lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override {
-    return lldb::eFormatDefault;
-  }
+  lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
 
   llvm::Expected<uint32_t>
   GetNumChildren(lldb::opaque_compiler_type_t type,
@@ -296,10 +313,9 @@ class TypeSystemFortran : public TypeSystem {
                  const ExecutionContext *exe_ctx) override {
     return 0;
   }
-
   lldb::BasicType
   GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override {
-    return lldb::eBasicTypeUnsignedInt;
+    return lldb::eBasicTypeInt;
   }
 
   uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override {
@@ -380,10 +396,7 @@ class TypeSystemFortran : public TypeSystem {
                      lldb::Format format, const DataExtractor &data,
                      lldb::offset_t data_offset, size_t data_byte_size,
                      uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
-                     ExecutionContextScope *exe_scope) override {
-    return false;
-  }
-
+                     ExecutionContextScope *exe_scope) override;
   /// Dump the type to stdout.
   void DumpTypeDescription(
       lldb::opaque_compiler_type_t type,
@@ -409,13 +422,10 @@ class TypeSystemFortran : public TypeSystem {
   void Dump(llvm::raw_ostream &output, llvm::StringRef filter,
             bool show_color) override {}
 
-  /// This is used by swift.
   bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override {
     return false;
   }
 
-  // TODO: Determine if these methods should move to TypeSystemClang.
-
   bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
                                 CompilerType *pointee_type) override {
     return false;
@@ -431,14 +441,10 @@ class TypeSystemFortran : public TypeSystem {
     return 0;
   }
 
-  CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override {
-    return CompilerType();
-  }
+  CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
 
   CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
-                                                   size_t bit_size) override {
-    return CompilerType();
-  }
+                                                   size_t bit_size) override;
 
   bool IsBeingDefined(lldb::opaque_compiler_type_t type) override {
     return false;
@@ -471,11 +477,15 @@ class TypeSystemFortran : public TypeSystem {
 
   CompilerType
   GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override {
-    return CompilerType();
+    if (!type)
+      return CompilerType();
+    return CompilerType(weak_from_this(), type);
   }
 
   CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override {
-    return CompilerType();
+    if (!type)
+      return CompilerType();
+    return CompilerType(weak_from_this(), type);
   }
 
   bool IsReferenceType(lldb::opaque_compiler_type_t type,
@@ -484,10 +494,18 @@ class TypeSystemFortran : public TypeSystem {
   }
 
 private:
+  ///
+  mutable llvm::FoldingSet<plugin::fortran::FortranType> m_basic_types;
+  mutable llvm::FoldingSet<plugin::fortran::FortranFunction> m_functions;
+  // We store all unique pointer types here so we can manage the lifecycle
+  // of the types without having to explicitly free them.
+  mutable llvm::SmallVector<std::unique_ptr<plugin::fortran::FortranType>>
+      m_types;
   std::unique_ptr<plugin::dwarf::DWARFASTParser> m_dwarf_ast_parser_up;
-
+  /// Store byte order of the system so variables can be printed correctly.
+  lldb::ByteOrder m_byte_order;
   TypeSystemFortran(const TypeSystemFortran &) = delete;
   const TypeSystemFortran &operator=(const TypeSystemFortran &) = delete;
 };
 } // namespace lldb_private
-#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
+#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_TYPESYSTEMFORTRAN_H
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/complex/Makefile b/lldb/test/API/lang/fortran/complex/Makefile
new file mode 100644
index 0000000000000..38f38c1339e5f
--- /dev/null
+++ b/lldb/test/API/lang/fortran/complex/Makefile
@@ -0,0 +1,3 @@
+F_SOURCES := complex.f90
+
+include Makefile.rules
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/complex/TestFortranComplex.py b/lldb/test/API/lang/fortran/complex/TestFortranComplex.py
new file mode 100644
index 0000000000000..a824adbdc9629
--- /dev/null
+++ b/lldb/test/API/lang/fortran/complex/TestFortranComplex.py
@@ -0,0 +1,33 @@
+"""
+Tests that the complex intrinsic type with different byte sizes works as expected 
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FortranTestComplex(TestBase):
+
+    def test_fortran_complex(self):
+        """Tests if complex return the correct name, kind and value."""
+        self.build()
+        self.main_source_file = lldb.SBFileSpec("complex.f90")
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "! Breakpoint here", self.main_source_file
+        )
+
+        frame = thread.GetFrameAtIndex(0)
+
+        complex_four = frame.FindVariable("complex_four")
+        self.assertSuccess(complex_four.GetError(), "Failed to fetch complex_four.")
+        self.assertEqual(complex_four.GetTypeName(), "COMPLEX")
+        self.assertEqual(complex_four.GetByteSize(), 8)
+        self.assertEqual(complex_four.GetValue(), "(2, 3)")
+
+        complex_eight = frame.FindVariable("complex_eight")
+        self.assertSuccess(complex_eight.GetError(), "Failed to fetch complex_eight.")
+        self.assertEqual(complex_eight.GetTypeName(), "COMPLEX(KIND=8)")
+        self.assertEqual(complex_eight.GetByteSize(), 16)
+        self.assertEqual(complex_eight.GetValue(), "(1, 4)")
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/complex/complex.f90 b/lldb/test/API/lang/fortran/complex/complex.f90
new file mode 100644
index 0000000000000..968014ab37a1a
--- /dev/null
+++ b/lldb/test/API/lang/fortran/complex/complex.f90
@@ -0,0 +1,13 @@
+program Complex
+  implicit none
+
+  complex(4) :: complex_four
+  complex(8) :: complex_eight
+
+  complex_four = (2.0, 3.0)
+
+  complex_eight = (1.0, 4.0)
+
+  print *, "Done" ! Breakpoint here
+
+end program Complex
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/frame-variable/Makefile b/lldb/test/API/lang/fortran/frame-variable/Makefile
new file mode 100644
index 0000000000000..98b6a7cc4f70a
--- /dev/null
+++ b/lldb/test/API/lang/fortran/frame-variable/Makefile
@@ -0,0 +1,3 @@
+F_SOURCES := frame.f90
+
+include Makefile.rules
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py b/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py
new file mode 100644
index 0000000000000..d323980e9a6e6
--- /dev/null
+++ b/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py
@@ -0,0 +1,27 @@
+"""
+Tests that the frame variable command works 
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FortranTestFrameVariable(TestBase):
+
+    def test_fortran_frame_variable(self):
+        """Tests if frame variable outputs the expected results"""
+        self.build()
+        self.main_source_file = lldb.SBFileSpec("frame.f90")
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "! Breakpoint here", self.main_source_file
+        )
+
+        self.expect("frame variable num_int", substrs=["(INTEGER) num_int = 152"])
+
+        self.expect("frame variable num_real", substrs=["(REAL) num_real = 2.718"])
+
+        self.expect("frame variable num_logical", substrs=["(LOGICAL) num_logical = true"])
+
+        self.expect("frame variable num_complex", substrs=["(COMPLEX) num_complex = (1.3, 2.6)"])
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/frame-variable/frame.f90 b/lldb/test/API/lang/fortran/frame-variable/frame.f90
new file mode 100644
index 0000000000000..2e6b066afb1d3
--- /dev/null
+++ b/lldb/test/API/lang/fortran/frame-variable/frame.f90
@@ -0,0 +1,17 @@
+program frameVariable
+  implicit none
+
+  real  :: num_real
+  integer :: num_int
+  logical :: num_logical
+  complex :: num_complex
+
+
+  num_int    = 152
+  num_real   = 2.718281828459045
+  num_logical = .TRUE.
+  num_complex = (1.3, 2.6)
+
+  print *, "Done" ! Breakpoint here
+
+end program frameVariable
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/integer/Makefile b/lldb/test/API/lang/fortran/integer/Makefile
new file mode 100644
index 0000000000000..0339201b206d6
--- /dev/null
+++ b/lldb/test/API/lang/fortran/integer/Makefile
@@ -0,0 +1,3 @@
+F_SOURCES := integers.f90
+
+include Makefile.rules
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py b/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py
new file mode 100644
index 0000000000000..6506b400f3fb2
--- /dev/null
+++ b/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py
@@ -0,0 +1,45 @@
+"""
+Tests that the integer intrinsic type with different byte sizes works as expected 
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FortranTestIntegers(TestBase):
+
+    def test_fortran_integers(self):
+        """Tests if integers return the correct name, kind and value."""
+        self.build()
+        self.main_source_file = lldb.SBFileSpec("integers.f90")
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "! Breakpoint here", self.main_source_file
+        )
+
+        frame = thread.GetFrameAtIndex(0)
+
+        tiny_int = frame.FindVariable("tiny_int")
+        self.assertSuccess(tiny_int.GetError(), "Failed to fetch tiny_int")
+        self.assertEqual(tiny_int.GetTypeName(), "INTEGER(KIND=1)")
+        self.assertEqual(tiny_int.GetByteSize(), 1)
+        self.assertEqual(tiny_int.GetValueAsSigned(), 127)
+
+        short_int = frame.FindVariable("short_int")
+        self.assertSuccess(short_int.GetError(), "Failed to fetch short_int")
+        self.assertEqual(short_int.GetTypeName(), "INTEGER(KIND=2)")
+        self.assertEqual(short_int.GetByteSize(), 2)
+        self.assertEqual(short_int.GetValueAsSigned(), 32767)
+        
+        normal_int = frame.FindVariable("normal_int")
+        self.assertSuccess(normal_int.GetError(), "Failed to fetch normal_int")
+        self.assertEqual(normal_int.GetTypeName(), "INTEGER")
+        self.assertEqual(normal_int.GetByteSize(), 4)
+        self.assertEqual(normal_int.GetValueAsSigned(), 2147483647)
+
+        huge_int = frame.FindVariable("huge_int")
+        self.assertSuccess(huge_int.GetError(), "Failed to fetch huge_int")
+        self.assertEqual(huge_int.GetTypeName(), "INTEGER(KIND=8)")
+        self.assertEqual(huge_int.GetByteSize(), 8)
+        self.assertEqual(huge_int.GetValueAsSigned(), 9223372036854775807)
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/integer/integers.f90 b/lldb/test/API/lang/fortran/integer/integers.f90
new file mode 100644
index 0000000000000..bf03c529160a3
--- /dev/null
+++ b/lldb/test/API/lang/fortran/integer/integers.f90
@@ -0,0 +1,16 @@
+program integer_kinds
+    implicit none
+
+    integer(1) :: tiny_int
+    integer(2) :: short_int
+    integer(4) :: normal_int
+    integer(8) :: huge_int
+
+    tiny_int   = 127
+    short_int  = 32767
+    normal_int = 2147483647
+    huge_int   = 9223372036854775807_8 
+
+    print *, "Done" ! Breakpoint here
+
+end program integer_kinds
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/lit.local.cfg b/lldb/test/API/lang/fortran/lit.local.cfg
new file mode 100644
index 0000000000000..5974aed7d275f
--- /dev/null
+++ b/lldb/test/API/lang/fortran/lit.local.cfg
@@ -0,0 +1,2 @@
+if not getattr(config, 'lldb_enable_fortran', False):
+  config.unsupported = True
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/logical/Makefile b/lldb/test/API/lang/fortran/logical/Makefile
new file mode 100644
index 0000000000000..848e5361dd976
--- /dev/null
+++ b/lldb/test/API/lang/fortran/logical/Makefile
@@ -0,0 +1,3 @@
+F_SOURCES := logical.f90
+
+include Makefile.rules
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/logical/TestFortranLogical.py b/lldb/test/API/lang/fortran/logical/TestFortranLogical.py
new file mode 100644
index 0000000000000..fa46b919fa99b
--- /dev/null
+++ b/lldb/test/API/lang/fortran/logical/TestFortranLogical.py
@@ -0,0 +1,45 @@
+"""
+Tests that the logical intrinsic type with different byte sizes works as expected 
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FortranTestLogicals(TestBase):
+
+    def test_fortran_logicals(self):
+        """Tests if logicals return the correct name, kind and value."""
+        self.build()
+        self.main_source_file = lldb.SBFileSpec("logical.f90")
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "! Breakpoint here", self.main_source_file
+        )
+
+        frame = thread.GetFrameAtIndex(0)
+
+        bool_one = frame.FindVariable("bool_one")
+        self.assertSuccess(bool_one.GetError(), "Failed to fetch bool_one")
+        self.assertEqual(bool_one.GetTypeName(), "LOGICAL(KIND=1)")
+        self.assertEqual(bool_one.GetByteSize(), 1)
+        self.assertEqual(bool_one.GetValue(), "true")
+
+        bool_two = frame.FindVariable("bool_two")
+        self.assertSuccess(bool_two.GetError(), "Failed to fetch bool_two")
+        self.assertEqual(bool_two.GetTypeName(), "LOGICAL(KIND=2)")
+        self.assertEqual(bool_two.GetByteSize(), 2)
+        self.assertEqual(bool_two.GetValue(), "false")
+        
+        bool_four = frame.FindVariable("bool_four")
+        self.assertSuccess(bool_four.GetError(), "Failed to fetch bool_four")
+        self.assertEqual(bool_four.GetTypeName(), "LOGICAL")
+        self.assertEqual(bool_four.GetByteSize(), 4)
+        self.assertEqual(bool_four.GetValue(), "true")
+
+        bool_eight = frame.FindVariable("bool_eight")
+        self.assertSuccess(bool_eight.GetError(), "Failed to fetch bool_eight")
+        self.assertEqual(bool_eight.GetTypeName(), "LOGICAL(KIND=8)")
+        self.assertEqual(bool_eight.GetByteSize(), 8)
+        self.assertEqual(bool_eight.GetValue(), "false")
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/logical/logical.f90 b/lldb/test/API/lang/fortran/logical/logical.f90
new file mode 100644
index 0000000000000..3ad72b03bfc94
--- /dev/null
+++ b/lldb/test/API/lang/fortran/logical/logical.f90
@@ -0,0 +1,17 @@
+program logical_kinds
+    implicit none
+
+    logical(1) :: bool_one
+    logical(2) :: bool_two
+    logical(4) :: bool_four
+    logical(8) :: bool_eight
+
+
+    bool_one   = .true.
+    bool_two   = .false.
+    bool_four  = .true.
+    bool_eight = .false.
+
+    print *, "Done" ! Breakpoint here
+
+end program logical_kinds
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/real/Makefile b/lldb/test/API/lang/fortran/real/Makefile
new file mode 100644
index 0000000000000..1564dfff256eb
--- /dev/null
+++ b/lldb/test/API/lang/fortran/real/Makefile
@@ -0,0 +1,3 @@
+F_SOURCES := real.f90
+
+include Makefile.rules
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/real/TestFortranReal.py b/lldb/test/API/lang/fortran/real/TestFortranReal.py
new file mode 100644
index 0000000000000..11ab2e70e5eb6
--- /dev/null
+++ b/lldb/test/API/lang/fortran/real/TestFortranReal.py
@@ -0,0 +1,33 @@
+"""
+Tests that the real intrinsic type with different byte sizes works as expected 
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FortranTestReal(TestBase):
+
+    def test_fortran_real(self):
+        """Tests if Real type return the correct name, kind and value."""
+        self.build()
+        self.main_source_file = lldb.SBFileSpec("real.f90")
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "! Breakpoint here", self.main_source_file
+        )
+
+        frame = thread.GetFrameAtIndex(0)
+        
+        float_four = frame.FindVariable("float_four")
+        self.assertSuccess(float_four.GetError(), "Failed to fetch float_four")
+        self.assertEqual(float_four.GetTypeName(), "REAL")
+        self.assertEqual(float_four.GetByteSize(), 4)
+        self.assertTrue(float_four.GetValue().startswith("3.14"), "float_four value is correct")
+
+        float_eight = frame.FindVariable("float_eight")
+        self.assertSuccess(float_eight.GetError(), "Failed to fetch float_eight")
+        self.assertEqual(float_eight.GetTypeName(), "REAL(KIND=8)")
+        self.assertEqual(float_eight.GetByteSize(), 8)
+        self.assertTrue(float_eight.GetValue().startswith("2.718"), "float_eight value is correct")
\ No newline at end of file
diff --git a/lldb/test/API/lang/fortran/real/real.f90 b/lldb/test/API/lang/fortran/real/real.f90
new file mode 100644
index 0000000000000..87b279a4f5777
--- /dev/null
+++ b/lldb/test/API/lang/fortran/real/real.f90
@@ -0,0 +1,12 @@
+program real_kinds
+    implicit none
+
+    real(4)  :: float_four
+    real(8)  :: float_eight
+
+    float_four    = 3.1415926_4
+    float_eight   = 2.718281828459045_8
+
+    print *, "Done" ! Breakpoint here
+
+end program real_kinds
\ No newline at end of file

>From 232d6130681fd1e9351c7a50b707a7e15b12894d Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Wed, 29 Jul 2026 22:16:17 +0300
Subject: [PATCH 11/12] [lldb] Fixed API test formatting

---
 .../lang/fortran/complex/TestFortranComplex.py    |  7 +++----
 .../frame-variable/TestFortranFrameVariable.py    | 13 ++++++++-----
 .../lang/fortran/integer/TestFortranIntegers.py   |  9 ++++-----
 .../lang/fortran/logical/TestFortranLogical.py    |  9 ++++-----
 .../test/API/lang/fortran/real/TestFortranReal.py | 15 +++++++++------
 5 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/lldb/test/API/lang/fortran/complex/TestFortranComplex.py b/lldb/test/API/lang/fortran/complex/TestFortranComplex.py
index a824adbdc9629..5e8ef05ec7759 100644
--- a/lldb/test/API/lang/fortran/complex/TestFortranComplex.py
+++ b/lldb/test/API/lang/fortran/complex/TestFortranComplex.py
@@ -1,8 +1,7 @@
 """
-Tests that the complex intrinsic type with different byte sizes works as expected 
+Tests that the complex intrinsic type with different byte sizes works as expected
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -14,7 +13,7 @@ def test_fortran_complex(self):
         """Tests if complex return the correct name, kind and value."""
         self.build()
         self.main_source_file = lldb.SBFileSpec("complex.f90")
-        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
             self, "! Breakpoint here", self.main_source_file
         )
 
@@ -30,4 +29,4 @@ def test_fortran_complex(self):
         self.assertSuccess(complex_eight.GetError(), "Failed to fetch complex_eight.")
         self.assertEqual(complex_eight.GetTypeName(), "COMPLEX(KIND=8)")
         self.assertEqual(complex_eight.GetByteSize(), 16)
-        self.assertEqual(complex_eight.GetValue(), "(1, 4)")
\ No newline at end of file
+        self.assertEqual(complex_eight.GetValue(), "(1, 4)")
diff --git a/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py b/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py
index d323980e9a6e6..34b149441c503 100644
--- a/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py
+++ b/lldb/test/API/lang/fortran/frame-variable/TestFortranFrameVariable.py
@@ -1,8 +1,7 @@
 """
-Tests that the frame variable command works 
+Tests that the frame variable command works
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -14,7 +13,7 @@ def test_fortran_frame_variable(self):
         """Tests if frame variable outputs the expected results"""
         self.build()
         self.main_source_file = lldb.SBFileSpec("frame.f90")
-        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
             self, "! Breakpoint here", self.main_source_file
         )
 
@@ -22,6 +21,10 @@ def test_fortran_frame_variable(self):
 
         self.expect("frame variable num_real", substrs=["(REAL) num_real = 2.718"])
 
-        self.expect("frame variable num_logical", substrs=["(LOGICAL) num_logical = true"])
+        self.expect(
+            "frame variable num_logical", substrs=["(LOGICAL) num_logical = true"]
+        )
 
-        self.expect("frame variable num_complex", substrs=["(COMPLEX) num_complex = (1.3, 2.6)"])
\ No newline at end of file
+        self.expect(
+            "frame variable num_complex", substrs=["(COMPLEX) num_complex = (1.3, 2.6)"]
+        )
diff --git a/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py b/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py
index 6506b400f3fb2..2cdfea757c9d1 100644
--- a/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py
+++ b/lldb/test/API/lang/fortran/integer/TestFortranIntegers.py
@@ -1,8 +1,7 @@
 """
-Tests that the integer intrinsic type with different byte sizes works as expected 
+Tests that the integer intrinsic type with different byte sizes works as expected
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -14,7 +13,7 @@ def test_fortran_integers(self):
         """Tests if integers return the correct name, kind and value."""
         self.build()
         self.main_source_file = lldb.SBFileSpec("integers.f90")
-        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
             self, "! Breakpoint here", self.main_source_file
         )
 
@@ -31,7 +30,7 @@ def test_fortran_integers(self):
         self.assertEqual(short_int.GetTypeName(), "INTEGER(KIND=2)")
         self.assertEqual(short_int.GetByteSize(), 2)
         self.assertEqual(short_int.GetValueAsSigned(), 32767)
-        
+
         normal_int = frame.FindVariable("normal_int")
         self.assertSuccess(normal_int.GetError(), "Failed to fetch normal_int")
         self.assertEqual(normal_int.GetTypeName(), "INTEGER")
@@ -42,4 +41,4 @@ def test_fortran_integers(self):
         self.assertSuccess(huge_int.GetError(), "Failed to fetch huge_int")
         self.assertEqual(huge_int.GetTypeName(), "INTEGER(KIND=8)")
         self.assertEqual(huge_int.GetByteSize(), 8)
-        self.assertEqual(huge_int.GetValueAsSigned(), 9223372036854775807)
\ No newline at end of file
+        self.assertEqual(huge_int.GetValueAsSigned(), 9223372036854775807)
diff --git a/lldb/test/API/lang/fortran/logical/TestFortranLogical.py b/lldb/test/API/lang/fortran/logical/TestFortranLogical.py
index fa46b919fa99b..4de7b43b1e857 100644
--- a/lldb/test/API/lang/fortran/logical/TestFortranLogical.py
+++ b/lldb/test/API/lang/fortran/logical/TestFortranLogical.py
@@ -1,8 +1,7 @@
 """
-Tests that the logical intrinsic type with different byte sizes works as expected 
+Tests that the logical intrinsic type with different byte sizes works as expected
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -14,7 +13,7 @@ def test_fortran_logicals(self):
         """Tests if logicals return the correct name, kind and value."""
         self.build()
         self.main_source_file = lldb.SBFileSpec("logical.f90")
-        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
             self, "! Breakpoint here", self.main_source_file
         )
 
@@ -31,7 +30,7 @@ def test_fortran_logicals(self):
         self.assertEqual(bool_two.GetTypeName(), "LOGICAL(KIND=2)")
         self.assertEqual(bool_two.GetByteSize(), 2)
         self.assertEqual(bool_two.GetValue(), "false")
-        
+
         bool_four = frame.FindVariable("bool_four")
         self.assertSuccess(bool_four.GetError(), "Failed to fetch bool_four")
         self.assertEqual(bool_four.GetTypeName(), "LOGICAL")
@@ -42,4 +41,4 @@ def test_fortran_logicals(self):
         self.assertSuccess(bool_eight.GetError(), "Failed to fetch bool_eight")
         self.assertEqual(bool_eight.GetTypeName(), "LOGICAL(KIND=8)")
         self.assertEqual(bool_eight.GetByteSize(), 8)
-        self.assertEqual(bool_eight.GetValue(), "false")
\ No newline at end of file
+        self.assertEqual(bool_eight.GetValue(), "false")
diff --git a/lldb/test/API/lang/fortran/real/TestFortranReal.py b/lldb/test/API/lang/fortran/real/TestFortranReal.py
index 11ab2e70e5eb6..2c9d72b804ec0 100644
--- a/lldb/test/API/lang/fortran/real/TestFortranReal.py
+++ b/lldb/test/API/lang/fortran/real/TestFortranReal.py
@@ -1,8 +1,7 @@
 """
-Tests that the real intrinsic type with different byte sizes works as expected 
+Tests that the real intrinsic type with different byte sizes works as expected
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -14,20 +13,24 @@ def test_fortran_real(self):
         """Tests if Real type return the correct name, kind and value."""
         self.build()
         self.main_source_file = lldb.SBFileSpec("real.f90")
-        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
             self, "! Breakpoint here", self.main_source_file
         )
 
         frame = thread.GetFrameAtIndex(0)
-        
+
         float_four = frame.FindVariable("float_four")
         self.assertSuccess(float_four.GetError(), "Failed to fetch float_four")
         self.assertEqual(float_four.GetTypeName(), "REAL")
         self.assertEqual(float_four.GetByteSize(), 4)
-        self.assertTrue(float_four.GetValue().startswith("3.14"), "float_four value is correct")
+        self.assertTrue(
+            float_four.GetValue().startswith("3.14"), "float_four value is correct"
+        )
 
         float_eight = frame.FindVariable("float_eight")
         self.assertSuccess(float_eight.GetError(), "Failed to fetch float_eight")
         self.assertEqual(float_eight.GetTypeName(), "REAL(KIND=8)")
         self.assertEqual(float_eight.GetByteSize(), 8)
-        self.assertTrue(float_eight.GetValue().startswith("2.718"), "float_eight value is correct")
\ No newline at end of file
+        self.assertTrue(
+            float_eight.GetValue().startswith("2.718"), "float_eight value is correct"
+        )

>From 89ad5dfd1af43e99457abf9a221836240a8818a3 Mon Sep 17 00:00:00 2001
From: Iasonaskrpr <iaskarapro at gmail.com>
Date: Sat, 1 Aug 2026 17:37:39 +0300
Subject: [PATCH 12/12] [lldb][Fortran] Added TypeSystemFortran tests and added
 GetBasicTypeEnumeration function to TypeSystemFortran

---
 .../TypeSystem/Fortran/TypeSystemFortran.cpp  |  52 +++
 .../TypeSystem/Fortran/TypeSystemFortran.h    |   4 +-
 lldb/unittests/Symbol/CMakeLists.txt          |   1 +
 .../Symbol/TestTypeSystemFortran.cpp          | 301 ++++++++++++++++++
 4 files changed, 355 insertions(+), 3 deletions(-)
 create mode 100644 lldb/unittests/Symbol/TestTypeSystemFortran.cpp

diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
index 4dcf16e21cda0..6ca80c3f4779f 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.cpp
@@ -312,6 +312,58 @@ TypeSystemFortran::GetBitSize(opaque_compiler_type_t type,
   return fortran_type->GetBitSize();
 }
 
+BasicType
+TypeSystemFortran::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
+  if (!type)
+    return eBasicTypeInvalid;
+  FortranType *fortran_type = static_cast<FortranType *>(type);
+  switch (fortran_type->GetKind()) {
+  case FortranType::KIND_INTEGER:
+    switch (fortran_type->GetBitSize()) {
+    case 8:
+      return eBasicTypeSignedChar;
+    case 16:
+      return eBasicTypeShort;
+    case 32:
+      return eBasicTypeInt;
+    case 64:
+      return eBasicTypeLongLong;
+    case 128:
+      return eBasicTypeInt128;
+    default:
+      return eBasicTypeInvalid;
+    }
+  case FortranType::KIND_LOGICAL:
+    return eBasicTypeBool;
+  case FortranType::KIND_COMPLEX:
+    switch (fortran_type->GetBitSize()) {
+    case 64:
+      return eBasicTypeFloatComplex;
+    case 128:
+      return eBasicTypeDoubleComplex;
+    case 256:
+      return eBasicTypeLongDoubleComplex;
+    default:
+      return eBasicTypeInvalid;
+    }
+  case FortranType::KIND_REAL:
+    switch (fortran_type->GetBitSize()) {
+    case 16:
+      return eBasicTypeHalf;
+    case 32:
+      return eBasicTypeFloat;
+    case 64:
+      return eBasicTypeDouble;
+    case 128:
+      return eBasicTypeFloat128;
+    default:
+      return eBasicTypeInvalid;
+    }
+  default:
+    return eBasicTypeInvalid;
+  }
+}
+
 Encoding TypeSystemFortran::GetEncoding(opaque_compiler_type_t type) {
   if (!type)
     return eEncodingInvalid;
diff --git a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
index 33699addfdded..3a76c994c7e72 100644
--- a/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
+++ b/lldb/source/Plugins/TypeSystem/Fortran/TypeSystemFortran.h
@@ -314,9 +314,7 @@ class TypeSystemFortran : public TypeSystem {
     return 0;
   }
   lldb::BasicType
-  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override {
-    return lldb::eBasicTypeInt;
-  }
+  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
 
   uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override {
     return 0;
diff --git a/lldb/unittests/Symbol/CMakeLists.txt b/lldb/unittests/Symbol/CMakeLists.txt
index f9794369a89f4..47dbf66dfa409 100644
--- a/lldb/unittests/Symbol/CMakeLists.txt
+++ b/lldb/unittests/Symbol/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lldb_unittest(SymbolTests
   SymStoreTest.cpp
   TestTypeSystem.cpp
   TestTypeSystemClang.cpp
+  TestTypeSystemFortran.cpp
   TestClangASTImporter.cpp
   TestDWARFCallFrameInfo.cpp
   TestType.cpp
diff --git a/lldb/unittests/Symbol/TestTypeSystemFortran.cpp b/lldb/unittests/Symbol/TestTypeSystemFortran.cpp
new file mode 100644
index 0000000000000..f2133145bb771
--- /dev/null
+++ b/lldb/unittests/Symbol/TestTypeSystemFortran.cpp
@@ -0,0 +1,301 @@
+//===-- TestTypeSystemFortran.cpp -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/TypeSystem/Fortran/FortranTypes.h"
+#include "Plugins/TypeSystem/Fortran/TypeSystemFortran.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/Core/Declaration.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::plugin::fortran;
+
+class TypeSystemFortranHolder {
+  std::shared_ptr<TypeSystemFortran> m_ast;
+
+public:
+  TypeSystemFortranHolder() : m_ast(std::make_shared<TypeSystemFortran>()) {}
+  TypeSystemFortran *GetAST() const { return m_ast.get(); }
+};
+
+class TestTypeSystemFortran : public testing::Test {
+public:
+  SubsystemRAII<FileSystem, HostInfo> subsystems;
+
+  void SetUp() override {
+    m_holder = std::make_unique<TypeSystemFortranHolder>();
+    m_ast = m_holder->GetAST();
+  }
+
+  void TearDown() override {
+    m_ast = nullptr;
+    m_holder.reset();
+  }
+
+protected:
+  TypeSystemFortran *m_ast = nullptr;
+  std::unique_ptr<TypeSystemFortranHolder> m_holder;
+};
+
+TEST_F(TestTypeSystemFortran, TestBaseTypes) {
+  CompilerType logical_type = m_ast->CreateType(llvm::dwarf::DW_ATE_boolean, 32,
+                                                ConstString("Logical"));
+  EXPECT_TRUE(logical_type.IsValid());
+  auto bitsize_or_err = logical_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 32U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(logical_type.GetOpaqueQualType()),
+            eBasicTypeBool);
+
+  CompilerType int8_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 8, ConstString());
+  EXPECT_TRUE(int8_type.IsValid());
+  bitsize_or_err = int8_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 8U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(int8_type.GetOpaqueQualType()),
+            eBasicTypeSignedChar);
+
+  CompilerType int16_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 16, ConstString());
+  EXPECT_TRUE(int16_type.IsValid());
+  bitsize_or_err = int16_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 16U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(int16_type.GetOpaqueQualType()),
+            eBasicTypeShort);
+
+  CompilerType int32_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString());
+  EXPECT_TRUE(int32_type.IsValid());
+  bitsize_or_err = int32_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 32U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(int32_type.GetOpaqueQualType()),
+            eBasicTypeInt);
+
+  CompilerType int64_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 64, ConstString());
+  EXPECT_TRUE(int64_type.IsValid());
+  bitsize_or_err = int64_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 64U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(int64_type.GetOpaqueQualType()),
+            eBasicTypeLongLong);
+
+  CompilerType int128_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 128, ConstString());
+  EXPECT_TRUE(int128_type.IsValid());
+  bitsize_or_err = int128_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 128U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(int128_type.GetOpaqueQualType()),
+            eBasicTypeInt128);
+
+  CompilerType real16_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 16, ConstString());
+  EXPECT_TRUE(real16_type.IsValid());
+  bitsize_or_err = real16_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 16U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(real16_type.GetOpaqueQualType()),
+            eBasicTypeHalf);
+
+  CompilerType real32_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 32, ConstString());
+  EXPECT_TRUE(real32_type.IsValid());
+  bitsize_or_err = real32_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 32U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(real32_type.GetOpaqueQualType()),
+            eBasicTypeFloat);
+
+  CompilerType real64_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 64, ConstString());
+  EXPECT_TRUE(real64_type.IsValid());
+  bitsize_or_err = real64_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 64U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(real64_type.GetOpaqueQualType()),
+            eBasicTypeDouble);
+
+  CompilerType real128_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 128, ConstString());
+  EXPECT_TRUE(real128_type.IsValid());
+  bitsize_or_err = real128_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 128U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(real128_type.GetOpaqueQualType()),
+            eBasicTypeFloat128);
+
+  CompilerType complex64_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 64, ConstString());
+  EXPECT_TRUE(complex64_type.IsValid());
+  bitsize_or_err = complex64_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 64U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(complex64_type.GetOpaqueQualType()),
+            eBasicTypeFloatComplex);
+
+  CompilerType complex128_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 128, ConstString());
+  EXPECT_TRUE(complex128_type.IsValid());
+  bitsize_or_err = complex128_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 128U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(complex128_type.GetOpaqueQualType()),
+            eBasicTypeDoubleComplex);
+
+  CompilerType complex256_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 256, ConstString());
+  EXPECT_TRUE(complex256_type.IsValid());
+  bitsize_or_err = complex256_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 256U);
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(complex256_type.GetOpaqueQualType()),
+            eBasicTypeLongDoubleComplex);
+
+  CompilerType invalid_int =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 42, ConstString());
+  EXPECT_EQ(m_ast->GetBasicTypeEnumeration(invalid_int.GetOpaqueQualType()),
+            eBasicTypeInvalid);
+}
+
+TEST_F(TestTypeSystemFortran, TestEncodingAndFormat) {
+  CompilerType logical_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_boolean, 32, ConstString());
+  CompilerType int_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString());
+  CompilerType real_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 32, ConstString());
+  CompilerType complex_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 64, ConstString());
+
+  EXPECT_EQ(logical_type.GetEncoding(), eEncodingUint);
+  EXPECT_EQ(int_type.GetEncoding(), eEncodingSint);
+  EXPECT_EQ(real_type.GetEncoding(), eEncodingIEEE754);
+  EXPECT_EQ(complex_type.GetEncoding(), eEncodingIEEE754);
+
+  EXPECT_EQ(logical_type.GetFormat(), eFormatBoolean);
+  EXPECT_EQ(int_type.GetFormat(), eFormatDecimal);
+  EXPECT_EQ(real_type.GetFormat(), eFormatFloat);
+  EXPECT_EQ(complex_type.GetFormat(), eFormatComplex);
+}
+
+TEST_F(TestTypeSystemFortran, TestTypeClassifications) {
+  CompilerType logical_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_boolean, 32, ConstString());
+  CompilerType int_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString());
+  CompilerType real_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 32, ConstString());
+  CompilerType complex_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 64, ConstString());
+
+  bool is_signed = false;
+
+  EXPECT_TRUE(int_type.IsIntegerType(is_signed));
+  EXPECT_TRUE(is_signed);
+  EXPECT_FALSE(logical_type.IsIntegerType(is_signed));
+  EXPECT_FALSE(real_type.IsIntegerType(is_signed));
+  EXPECT_FALSE(complex_type.IsIntegerType(is_signed));
+
+  EXPECT_TRUE(real_type.IsFloatingPointType());
+  EXPECT_FALSE(int_type.IsFloatingPointType());
+  EXPECT_FALSE(logical_type.IsFloatingPointType());
+  EXPECT_FALSE(complex_type.IsFloatingPointType());
+}
+
+TEST_F(TestTypeSystemFortran, TestGetTypeInfo) {
+  CompilerType int_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString());
+  CompilerType real_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 32, ConstString());
+  CompilerType complex_type =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 64, ConstString());
+
+  uint32_t int_flags = int_type.GetTypeInfo();
+  EXPECT_TRUE(int_flags & eTypeIsBuiltIn);
+  EXPECT_TRUE(int_flags & eTypeHasValue);
+  EXPECT_TRUE(int_flags & eTypeIsScalar);
+  EXPECT_TRUE(int_flags & eTypeIsInteger);
+  EXPECT_TRUE(int_flags & eTypeIsSigned);
+
+  uint32_t real_flags = real_type.GetTypeInfo();
+  EXPECT_TRUE(real_flags & eTypeIsScalar);
+  EXPECT_TRUE(real_flags & eTypeIsFloat);
+
+  uint32_t complex_flags = complex_type.GetTypeInfo();
+  EXPECT_TRUE(complex_flags & eTypeIsComplex);
+  EXPECT_FALSE(complex_flags & eTypeIsScalar);
+}
+
+TEST_F(TestTypeSystemFortran, TestTypeNameGeneration) {
+  CompilerType logical32 =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_boolean, 32, ConstString());
+  CompilerType int32 =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString());
+  CompilerType real32 =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 32, ConstString());
+  CompilerType complex64 =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_complex_float, 64, ConstString());
+
+  EXPECT_STREQ(logical32.GetTypeName().GetCString(), "LOGICAL");
+  EXPECT_STREQ(int32.GetTypeName().GetCString(), "INTEGER");
+  EXPECT_STREQ(real32.GetTypeName().GetCString(), "REAL");
+  EXPECT_STREQ(complex64.GetTypeName().GetCString(), "COMPLEX");
+}
+
+TEST_F(TestTypeSystemFortran, TestFortranFunction) {
+  CompilerType int_param =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString("INTEGER"));
+  CompilerType real_param =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_float, 64, ConstString("REAL(8)"));
+
+  llvm::SmallVector<CompilerType, 2> params = {int_param, real_param};
+
+  CompilerType func_type =
+      m_ast->GetOrCreateFortranFunction(ConstString("my_subroutine"), params);
+  EXPECT_TRUE(func_type.IsValid());
+
+  auto *fortran_func =
+      static_cast<FortranFunction *>(func_type.GetOpaqueQualType());
+  EXPECT_EQ(fortran_func->GetKind(), FortranType::KIND_FUNCTION);
+  EXPECT_EQ(fortran_func->GetNumberOfParameters(), 2U);
+  EXPECT_EQ(fortran_func->GetName().GetStringRef(), "my_subroutine");
+}
+
+TEST_F(TestTypeSystemFortran, TestFoldingSetDeduplication) {
+  CompilerType int1 =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString("INTEGER"));
+
+  CompilerType int2 =
+      m_ast->CreateType(llvm::dwarf::DW_ATE_signed, 32, ConstString("INTEGER"));
+
+  EXPECT_EQ(int1.GetOpaqueQualType(), int2.GetOpaqueQualType());
+}
+
+TEST_F(TestTypeSystemFortran, TestGetBasicTypeFromAST) {
+  CompilerType int_type = m_ast->GetBasicTypeFromAST(eBasicTypeInt);
+  EXPECT_TRUE(int_type.IsValid());
+  EXPECT_STREQ(int_type.GetTypeName().GetCString(), "INTEGER");
+
+  auto bitsize_or_err = int_type.GetBitSize(nullptr);
+  ASSERT_THAT_EXPECTED(bitsize_or_err, llvm::Succeeded());
+  EXPECT_EQ(*bitsize_or_err, 32U);
+
+  CompilerType complex_type =
+      m_ast->GetBasicTypeFromAST(eBasicTypeDoubleComplex);
+  EXPECT_TRUE(complex_type.IsValid());
+  EXPECT_STREQ(complex_type.GetTypeName().GetCString(), "COMPLEX(KIND=8)");
+}
\ No newline at end of file



More information about the lldb-commits mailing list