[libcxx-commits] [PATCH] D100703: [libc++] [CI] Fail if the headers contain cyclic dependencies

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 17 10:57:07 PDT 2021


Quuxplusone updated this revision to Diff 338327.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100703/new/

https://reviews.llvm.org/D100703

Files:
  libcxx/utils/ci/run-buildbot
  libcxx/utils/graph_header_deps.py


Index: libcxx/utils/graph_header_deps.py
===================================================================
--- libcxx/utils/graph_header_deps.py
+++ libcxx/utils/graph_header_deps.py
@@ -10,6 +10,7 @@
 import argparse
 import os
 import re
+import sys
 
 
 def is_config_header(h):
@@ -61,14 +62,18 @@
     system_includes = []
     linecount = 0
     with open(fname, 'r') as f:
-        for line in f.readlines():
-            linecount += 1
-            m = re.match(r'\s*#\s*include\s+"([^"]*)"', line)
-            if m is not None:
-                local_includes.append(m.group(1))
-            m = re.match(r'\s*#\s*include\s+<([^>]*)>', line)
-            if m is not None:
-                system_includes.append(m.group(1))
+        try:
+            for line in f.readlines():
+                linecount += 1
+                m = re.match(r'\s*#\s*include\s+"([^"]*)"', line)
+                if m is not None:
+                    local_includes.append(m.group(1))
+                m = re.match(r'\s*#\s*include\s+<([^>]*)>', line)
+                if m is not None:
+                    system_includes.append(m.group(1))
+        except UnicodeDecodeError as e:
+            sys.stderr.write('Non-ASCII detected in %s\n' % fname)
+            raise
 
     fully_qualified_includes = [
         locate_header_file(h, options.search_dirs)
Index: libcxx/utils/ci/run-buildbot
===================================================================
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -142,6 +142,8 @@
     git diff | tee ${BUILD_DIR}/generated_output.patch
     # Check if the diffs are empty, fail otherwise.
     ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch
+    # Check that no dependency cycles have been introduced.
+    python3 libcxx/utils/graph_header_deps.py >/dev/null
 ;;
 generic-cxx03)
     export CC=clang


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100703.338327.patch
Type: text/x-patch
Size: 1873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210417/ab591db0/attachment-0001.bin>


More information about the libcxx-commits mailing list