[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 15:34:48 PDT 2021


Quuxplusone updated this revision to Diff 338344.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100703

Files:
  libcxx/include/__memory/pointer_traits.h
  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):
@@ -60,15 +61,19 @@
     local_includes = []
     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))
+    with open(fname, 'r', encoding='ascii') as f:
+        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)
@@ -204,7 +209,7 @@
     for fname, entry in graph.items():
         for h in entry.includes:
             if transitively_includes(graph, h, fname):
-                print('Cycle detected between %s and %s' % (fname, h))
+                sys.stderr.write('Cycle detected between %s and %s\n' % (fname, h))
                 no_cycles_detected = False
     assert no_cycles_detected
 
Index: libcxx/utils/ci/run-buildbot
===================================================================
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -134,14 +134,19 @@
 ;;
 check-generated-output)
     clean
-    echo "+++ Checking the output of the generated scripts"
+    echo "+++ Checking the output of the generator scripts"
     mkdir -p ${BUILD_DIR}
+    # Reject patches that introduce non-ASCII characters or hard tabs.
+    ! grep -r '[^ -~]' libcxx/include/
+    # Reject patches that don't update the generated output correctly.
     python3 libcxx/utils/generate_feature_test_macro_components.py
     python3 libcxx/utils/generate_header_inclusion_tests.py
     python3 libcxx/utils/generate_header_tests.py
     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
Index: libcxx/include/__memory/pointer_traits.h
===================================================================
--- libcxx/include/__memory/pointer_traits.h
+++ libcxx/include/__memory/pointer_traits.h
@@ -11,6 +11,7 @@
 #define _LIBCPP___MEMORY_POINTER_TRAITS_H
 
 #include <__config>
+#include <scoped_allocator>
 #include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)


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


More information about the libcxx-commits mailing list