[Lldb-commits] [lldb] [lldb][Fortran] Added DWARFASTParser for Fortran (PR #218024)
Iasonas Karaprodromidis via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 7 06:49:40 PDT 2026
================
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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"
+
+#include "FortranLanguage.h"
+
+#include "lldb/Core/PluginManager.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) {
+ if (Language::LanguageIsFortran(language)) {
+ return new FortranLanguage();
+ }
+ return nullptr;
+}
+
+bool FortranLanguage::IsSourceFile(StringRef file_path) const {
+ const auto suffixes = {".f90", ".f", ".f95", ".f03", ".f08",
+ ".f18", ".for", ".ftn", ".fpp", ",f77"};
+ for (auto suffix : suffixes) {
+ if (file_path.ends_with_insensitive(suffix))
----------------
Iasonaskrpr wrote:
I assume you are talking about llvm::sys::path::extension?
All other plugins do it this way, but I can change if it is better this way.
https://github.com/llvm/llvm-project/pull/218024
More information about the lldb-commits
mailing list