[04/17] corpus: Support adding translation units with empty path

Message ID 20240716145541.473065-5-dodji@redhat.com
State New
Headers
Series Support self comparison of vmlinux & modules using BTF/CTF |

Commit Message

Dodji Seketeli July 16, 2024, 2:55 p.m. UTC
  From: Dodji Seketeli <dodji@redhat.com>

The CTF front-end produces an artificial translation unit with an
empty path for all the types in a given ABI corpus.  Adding such a
translation unit to its corpus is conditioned on it having a non-empty
path.  Oops.  Fixed thus.

	* src/abg-corpus.cc (corpus::add): Do not require that the path of
	the translation unit be non-empty.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-corpus.cc | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
  

Patch

diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc
index 1239deb0..994307fb 100644
--- a/src/abg-corpus.cc
+++ b/src/abg-corpus.cc
@@ -14,6 +14,7 @@ 
 #include <stdexcept>
 #include <unordered_map>
 #include <set>
+#include <memory>
 
 #include "abg-internal.h"
 
@@ -724,14 +725,11 @@  corpus::add(const translation_unit_sptr& tu)
 {
   ABG_ASSERT(priv_->members.insert(tu).second);
 
-  if (!tu->get_absolute_path().empty())
-    {
-      // Update the path -> translation_unit map.
-      string_tu_map_type::const_iterator i =
-	priv_->path_tu_map.find(tu->get_absolute_path());
-      ABG_ASSERT(i == priv_->path_tu_map.end());
-      priv_->path_tu_map[tu->get_absolute_path()] = tu;
-    }
+  // Update the path -> translation_unit map.
+  string_tu_map_type::const_iterator i =
+    priv_->path_tu_map.find(tu->get_absolute_path());
+  ABG_ASSERT(i == priv_->path_tu_map.end());
+  priv_->path_tu_map[tu->get_absolute_path()] = tu;
 
   tu->set_corpus(this);
 }