[libcxx-commits] [libcxx] e5fbe9f - [libc++] graph_header_deps.py: Detect files that include themselves.

Arthur O'Dwyer via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 30 14:39:21 PDT 2021


Author: Arthur O'Dwyer
Date: 2021-06-30T17:37:43-04:00
New Revision: e5fbe9f3150b5f810673590ca50a0ee793e120d1

URL: https://github.com/llvm/llvm-project/commit/e5fbe9f3150b5f810673590ca50a0ee793e120d1
DIFF: https://github.com/llvm/llvm-project/commit/e5fbe9f3150b5f810673590ca50a0ee793e120d1.diff

LOG: [libc++] graph_header_deps.py: Detect files that include themselves.

This wasn't happening before, which led to one slipping in.

Added: 
    

Modified: 
    libcxx/include/__ranges/subrange.h
    libcxx/utils/graph_header_deps.py

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h
index f365fb7466cb..8ce20bd180bf 100644
--- a/libcxx/include/__ranges/subrange.h
+++ b/libcxx/include/__ranges/subrange.h
@@ -18,7 +18,6 @@
 #include <__ranges/concepts.h>
 #include <__ranges/enable_borrowed_range.h>
 #include <__ranges/size.h>
-#include <__ranges/subrange.h>
 #include <__ranges/view_interface.h>
 #include <concepts>
 #include <type_traits>

diff  --git a/libcxx/utils/graph_header_deps.py b/libcxx/utils/graph_header_deps.py
index bccd22c61d80..95b0a482ae09 100755
--- a/libcxx/utils/graph_header_deps.py
+++ b/libcxx/utils/graph_header_deps.py
@@ -209,7 +209,12 @@ def should_keep(fname):
     no_cycles_detected = True
     for fname, entry in graph.items():
         for h in entry.includes:
-            if transitively_includes(graph, h, fname):
+            if h == fname:
+                sys.stderr.write('Cycle detected: %s includes itself\n' % (
+                    get_friendly_id(fname)
+                ))
+                no_cycles_detected = False
+            elif transitively_includes(graph, h, fname):
                 sys.stderr.write('Cycle detected between %s and %s\n' % (
                     get_friendly_id(fname), get_friendly_id(h)
                 ))


        


More information about the libcxx-commits mailing list