[flang-commits] [flang] [flang] Use module file hashes for more checking and disambiguation (PR #80354)

via flang-commits flang-commits at lists.llvm.org
Fri Feb 2 07:23:55 PST 2024


================
@@ -0,0 +1,39 @@
+//===-- include/flang/Semantics/module-dependences.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 FORTRAN_SEMANTICS_MODULE_DEPENDENCES_H_
+#define FORTRAN_SEMANTICS_MODULE_DEPENDENCES_H_
+
+#include <cinttypes>
+#include <map>
+#include <optional>
+#include <string>
+
+namespace Fortran::semantics {
+
+using ModuleCheckSumType = std::uint64_t;
+
+class ModuleDependences {
+public:
+  void AddDependence(std::string &&name, ModuleCheckSumType hash) {
+    map_.emplace(std::move(name), hash);
----------------
jeanPerier wrote:

Is it possible to have indirect uses of two modules with the same name in the same compilation unit as illustrated below? If so, this would not be handled given there is a single mapping in the SemanticContext for the whole compilation unit, right?


```
   ┌───────────┐       ┌───────────┐
   │   File1   │       │   File2   │
   │Define  M0 │       │ Define M0 │
   └─────┬─────┘       └──────┬────┘
         │                    │
         │                    │
┌────────▼────────┐  ┌────────▼────────┐
│      File3      │  │     File 4      │
│Use M0 from File1│  │Use M0 from File2│
│   Define M1     │  │   Define M2     │
└──────────┬──────┘  └──┬──────────────┘
           │            │
        ┌──▼────────────▼─┐
        │     File5       │
        │ Use M1 and M2   │
        └─────────────────┘
```

https://github.com/llvm/llvm-project/pull/80354


More information about the flang-commits mailing list