forked from OSchip/llvm-project
[libc++] Avoids self references in transitive include test.
The output of --trace-includes starts with the header whose includes are being processed. Since the sanitize script processed all lines this include was added to the list of transitive includes. This looks odd since it implies all headers have a cyclic dependency on themselves. This change removes this self-include. Instead of just dropping the first line extract that header and use it to guard against cyclic dependencies in the header itself. The regex used has a small improvement; don't capture groups that aren't extracted. Depends on D132284 Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D132787
This commit is contained in:
parent
cb84721c3c
commit
9185d6e6bc
|
@ -11,28 +11,66 @@
|
|||
# Specifically, it looks for lines of the form 'c++/v1/header' where 'header' is the name
|
||||
# of a public C++ header, excluding C compatibility headers.
|
||||
|
||||
# The input looks like
|
||||
#. ${build_dir}/include/c++/v1/algorithm
|
||||
#.. ${build_dir}/include/c++/v1/__assert
|
||||
#... ${build_dir}/include/c++/v1/__config
|
||||
#.... ${build_dir}/include/c++/v1/__config_site
|
||||
#.... /usr/include/features.h
|
||||
#..... /usr/include/stdc-predef.h
|
||||
#..... /usr/include/x86_64-linux-gnu/sys/cdefs.h
|
||||
#...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
|
||||
# <snip>
|
||||
#.... ${build_dir}/include/c++/v1/version
|
||||
#.... ${build_dir}/include/c++/v1/stddef.h
|
||||
#..... /usr/lib/llvm-15/lib/clang/15.0.0/include/stddef.h
|
||||
#...... /usr/lib/llvm-15/lib/clang/15.0.0/include/__stddef_max_align_t.h
|
||||
#... ${build_dir}/include/c++/v1/type_traits
|
||||
# <more>
|
||||
|
||||
# The first line matched libc++ header contains the name of the header being
|
||||
# evaluated. The might be other headers before, for example ASAN adds
|
||||
# additional headers. The filtered output will be like:
|
||||
# version
|
||||
# type_traits
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Determine the top-level header in the input.
|
||||
top_level_header = None
|
||||
while True:
|
||||
line = sys.stdin.readline()
|
||||
# On Windows, the path separators can either be forward slash or backslash.
|
||||
# If it is a backslash, Clang prints it escaped as two consecutive
|
||||
# backslashes, and they need to be escaped in the RE. (Use a raw string for
|
||||
# the pattern to avoid needing another level of escaping on the Python string
|
||||
# literal level.)
|
||||
match = re.match(
|
||||
r". .*(?:/|\\\\)include(?:/|\\\\)c\+\+(?:/|\\\\)v[0-9]+(?:/|\\\\)(.+)", line
|
||||
)
|
||||
if match:
|
||||
top_level_header = match.group(1)
|
||||
break
|
||||
|
||||
# Filter out non Standard transitive includes.
|
||||
headers = []
|
||||
for line in sys.stdin.readlines():
|
||||
# On Windows, the path separators can either be forward slash or backslash.
|
||||
# If it is a backslash, Clang prints it escaped as two consecutive
|
||||
# backslashes, and they need to be escaped in the RE. (Use a raw string for
|
||||
# the pattern to avoid needing another level of escaping on the Python string
|
||||
# literal level.)
|
||||
match = re.search(r'c\+\+(/|\\\\)v[0-9]+(/|\\\\)(.+)', line)
|
||||
if not match:
|
||||
continue
|
||||
match = re.search(r"c\+\+(?:/|\\\\)v[0-9]+(?:/|\\\\)(.+)", line)
|
||||
if not match:
|
||||
continue
|
||||
|
||||
header = match.group(3)
|
||||
if os.path.basename(header).endswith('.h'): # Skip C headers
|
||||
continue
|
||||
header = match.group(1)
|
||||
if os.path.basename(header).endswith(".h"): # Skip C headers
|
||||
continue
|
||||
|
||||
if os.path.basename(header).startswith('__'): # Skip internal headers
|
||||
continue
|
||||
if os.path.basename(header).startswith("__"): # Skip internal headers
|
||||
continue
|
||||
|
||||
headers.append(header)
|
||||
if header == top_level_header:
|
||||
sys.exit(f"Cyclic dependency in header {header}")
|
||||
|
||||
print('\n'.join(sorted(set(headers))))
|
||||
headers.append(header)
|
||||
|
||||
print("\n".join(sorted(set(headers))))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
algorithm
|
||||
atomic
|
||||
bit
|
||||
chrono
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
any
|
||||
atomic
|
||||
chrono
|
||||
climits
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
algorithm
|
||||
array
|
||||
atomic
|
||||
bit
|
||||
chrono
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
atomic
|
||||
chrono
|
||||
climits
|
||||
cmath
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
atomic
|
||||
barrier
|
||||
chrono
|
||||
climits
|
||||
cmath
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
bit
|
||||
cstddef
|
||||
cstdint
|
||||
cstdlib
|
||||
|
|
|
@ -2,7 +2,6 @@ algorithm
|
|||
array
|
||||
atomic
|
||||
bit
|
||||
bitset
|
||||
cctype
|
||||
chrono
|
||||
climits
|
||||
|
|
|
@ -1 +1 @@
|
|||
cassert
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ array
|
|||
atomic
|
||||
bit
|
||||
bitset
|
||||
ccomplex
|
||||
cctype
|
||||
cerrno
|
||||
chrono
|
||||
|
|
|
@ -1 +1 @@
|
|||
cctype
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cerrno
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cfenv
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cfloat
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
cerrno
|
||||
charconv
|
||||
cmath
|
||||
concepts
|
||||
cstddef
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
chrono
|
||||
climits
|
||||
cmath
|
||||
compare
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
cinttypes
|
||||
cstdint
|
||||
|
|
|
@ -1 +1 @@
|
|||
ciso646
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
climits
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
clocale
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
cmath
|
||||
cstddef
|
||||
cstdint
|
||||
limits
|
||||
|
|
|
@ -7,7 +7,6 @@ cerrno
|
|||
chrono
|
||||
climits
|
||||
cmath
|
||||
codecvt
|
||||
compare
|
||||
concepts
|
||||
cstddef
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
cmath
|
||||
compare
|
||||
cstddef
|
||||
cstdint
|
||||
limits
|
||||
|
|
|
@ -9,7 +9,6 @@ chrono
|
|||
climits
|
||||
cmath
|
||||
compare
|
||||
complex
|
||||
concepts
|
||||
cstdarg
|
||||
cstddef
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
concepts
|
||||
cstddef
|
||||
cstdint
|
||||
type_traits
|
||||
|
|
|
@ -9,7 +9,6 @@ climits
|
|||
cmath
|
||||
compare
|
||||
concepts
|
||||
condition_variable
|
||||
cstddef
|
||||
cstdint
|
||||
cstdio
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
cmath
|
||||
compare
|
||||
coroutine
|
||||
cstddef
|
||||
cstdint
|
||||
cstring
|
||||
|
|
|
@ -1 +1 @@
|
|||
csetjmp
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
csignal
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cstdarg
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cstdbool
|
||||
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
cstddef
|
||||
version
|
||||
|
|
|
@ -1 +1 @@
|
|||
cstdint
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cstdio
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cstdlib
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cstring
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ cstdint
|
|||
cstdio
|
||||
cstdlib
|
||||
cstring
|
||||
ctgmath
|
||||
ctime
|
||||
cwchar
|
||||
cwctype
|
||||
|
|
|
@ -1 +1 @@
|
|||
ctime
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
cuchar
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cctype
|
||||
cwchar
|
||||
cwctype
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
cctype
|
||||
cwctype
|
||||
|
|
|
@ -12,7 +12,6 @@ cstdint
|
|||
cstdlib
|
||||
cstring
|
||||
ctime
|
||||
deque
|
||||
exception
|
||||
functional
|
||||
initializer_list
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
cstddef
|
||||
cstdint
|
||||
cstdlib
|
||||
exception
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
execution
|
||||
version
|
||||
|
|
|
@ -12,7 +12,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/algorithm
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
|
|
|
@ -10,7 +10,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/coroutine
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
|
|
|
@ -14,7 +14,6 @@ cstring
|
|||
ctime
|
||||
deque
|
||||
exception
|
||||
experimental/deque
|
||||
experimental/memory_resource
|
||||
experimental/utility
|
||||
functional
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/forward_list
|
||||
experimental/memory_resource
|
||||
experimental/utility
|
||||
forward_list
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/functional
|
||||
functional
|
||||
initializer_list
|
||||
iosfwd
|
||||
|
|
|
@ -6,7 +6,6 @@ cstdint
|
|||
cstdlib
|
||||
cstring
|
||||
exception
|
||||
experimental/iterator
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/list
|
||||
experimental/memory_resource
|
||||
experimental/utility
|
||||
functional
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/map
|
||||
experimental/memory_resource
|
||||
experimental/utility
|
||||
functional
|
||||
|
|
|
@ -10,7 +10,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/memory_resource
|
||||
experimental/utility
|
||||
initializer_list
|
||||
iosfwd
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
cstddef
|
||||
cstdint
|
||||
experimental/propagate_const
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -20,7 +20,6 @@ cwctype
|
|||
deque
|
||||
exception
|
||||
experimental/memory_resource
|
||||
experimental/regex
|
||||
experimental/string
|
||||
experimental/utility
|
||||
functional
|
||||
|
|
|
@ -14,7 +14,6 @@ cstring
|
|||
ctime
|
||||
exception
|
||||
experimental/memory_resource
|
||||
experimental/set
|
||||
experimental/utility
|
||||
functional
|
||||
initializer_list
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
experimental/simd
|
||||
functional
|
||||
initializer_list
|
||||
iosfwd
|
||||
|
|
|
@ -18,7 +18,6 @@ cwchar
|
|||
cwctype
|
||||
exception
|
||||
experimental/memory_resource
|
||||
experimental/string
|
||||
experimental/utility
|
||||
functional
|
||||
initializer_list
|
||||
|
|
|
@ -1 +1 @@
|
|||
experimental/type_traits
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ cstring
|
|||
ctime
|
||||
exception
|
||||
experimental/memory_resource
|
||||
experimental/unordered_map
|
||||
experimental/utility
|
||||
functional
|
||||
initializer_list
|
||||
|
|
|
@ -14,7 +14,6 @@ cstring
|
|||
ctime
|
||||
exception
|
||||
experimental/memory_resource
|
||||
experimental/unordered_set
|
||||
experimental/utility
|
||||
functional
|
||||
initializer_list
|
||||
|
|
|
@ -3,7 +3,6 @@ compare
|
|||
cstddef
|
||||
cstdint
|
||||
cstdlib
|
||||
experimental/utility
|
||||
initializer_list
|
||||
iosfwd
|
||||
limits
|
||||
|
|
|
@ -14,7 +14,6 @@ ctime
|
|||
exception
|
||||
experimental/memory_resource
|
||||
experimental/utility
|
||||
experimental/vector
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
|
|
|
@ -17,7 +17,6 @@ ctime
|
|||
cwchar
|
||||
cwctype
|
||||
exception
|
||||
ext/hash_map
|
||||
functional
|
||||
initializer_list
|
||||
iosfwd
|
||||
|
|
|
@ -17,7 +17,6 @@ ctime
|
|||
cwchar
|
||||
cwctype
|
||||
exception
|
||||
ext/hash_set
|
||||
functional
|
||||
initializer_list
|
||||
iosfwd
|
||||
|
|
|
@ -20,7 +20,6 @@ ctime
|
|||
cwchar
|
||||
cwctype
|
||||
exception
|
||||
filesystem
|
||||
functional
|
||||
initializer_list
|
||||
iomanip
|
||||
|
|
|
@ -20,7 +20,6 @@ ctime
|
|||
cwchar
|
||||
cwctype
|
||||
exception
|
||||
format
|
||||
functional
|
||||
initializer_list
|
||||
ios
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
forward_list
|
||||
functional
|
||||
initializer_list
|
||||
iosfwd
|
||||
|
|
|
@ -21,7 +21,6 @@ cwchar
|
|||
cwctype
|
||||
exception
|
||||
filesystem
|
||||
fstream
|
||||
functional
|
||||
initializer_list
|
||||
iomanip
|
||||
|
|
|
@ -13,7 +13,6 @@ cstdlib
|
|||
cstring
|
||||
ctime
|
||||
exception
|
||||
functional
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
|
|
|
@ -19,7 +19,6 @@ cwchar
|
|||
cwctype
|
||||
exception
|
||||
functional
|
||||
future
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
cstddef
|
||||
initializer_list
|
||||
version
|
||||
|
|
|
@ -22,7 +22,6 @@ cwctype
|
|||
exception
|
||||
functional
|
||||
initializer_list
|
||||
iomanip
|
||||
ios
|
||||
iosfwd
|
||||
istream
|
||||
|
|
|
@ -20,7 +20,6 @@ cwctype
|
|||
exception
|
||||
functional
|
||||
initializer_list
|
||||
ios
|
||||
iosfwd
|
||||
iterator
|
||||
limits
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
iosfwd
|
||||
version
|
||||
|
|
|
@ -24,7 +24,6 @@ functional
|
|||
initializer_list
|
||||
ios
|
||||
iosfwd
|
||||
iostream
|
||||
istream
|
||||
iterator
|
||||
limits
|
||||
|
|
|
@ -24,7 +24,6 @@ functional
|
|||
initializer_list
|
||||
ios
|
||||
iosfwd
|
||||
istream
|
||||
iterator
|
||||
limits
|
||||
locale
|
||||
|
|
|
@ -8,7 +8,6 @@ cstring
|
|||
exception
|
||||
initializer_list
|
||||
iosfwd
|
||||
iterator
|
||||
limits
|
||||
new
|
||||
tuple
|
||||
|
|
|
@ -8,7 +8,6 @@ cstdint
|
|||
cstring
|
||||
ctime
|
||||
iosfwd
|
||||
latch
|
||||
limits
|
||||
ratio
|
||||
type_traits
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
cstddef
|
||||
cstdint
|
||||
limits
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -18,7 +18,6 @@ initializer_list
|
|||
iosfwd
|
||||
iterator
|
||||
limits
|
||||
list
|
||||
memory
|
||||
new
|
||||
optional
|
||||
|
|
|
@ -25,7 +25,6 @@ ios
|
|||
iosfwd
|
||||
iterator
|
||||
limits
|
||||
locale
|
||||
memory
|
||||
mutex
|
||||
new
|
||||
|
|
|
@ -18,7 +18,6 @@ initializer_list
|
|||
iosfwd
|
||||
iterator
|
||||
limits
|
||||
map
|
||||
memory
|
||||
new
|
||||
optional
|
||||
|
|
|
@ -14,7 +14,6 @@ initializer_list
|
|||
iosfwd
|
||||
iterator
|
||||
limits
|
||||
memory
|
||||
new
|
||||
ratio
|
||||
stdexcept
|
||||
|
|
|
@ -24,7 +24,6 @@ iosfwd
|
|||
iterator
|
||||
limits
|
||||
memory
|
||||
mutex
|
||||
new
|
||||
optional
|
||||
ratio
|
||||
|
|
|
@ -2,6 +2,5 @@ cstddef
|
|||
cstdint
|
||||
cstdlib
|
||||
exception
|
||||
new
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
concepts
|
||||
cstddef
|
||||
cstdint
|
||||
numbers
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -20,7 +20,6 @@ iterator
|
|||
limits
|
||||
memory
|
||||
new
|
||||
numeric
|
||||
optional
|
||||
ratio
|
||||
stdexcept
|
||||
|
|
|
@ -16,7 +16,6 @@ iterator
|
|||
limits
|
||||
memory
|
||||
new
|
||||
optional
|
||||
ratio
|
||||
stdexcept
|
||||
tuple
|
||||
|
|
|
@ -31,7 +31,6 @@ memory
|
|||
mutex
|
||||
new
|
||||
optional
|
||||
ostream
|
||||
ratio
|
||||
stdexcept
|
||||
streambuf
|
||||
|
|
|
@ -22,7 +22,6 @@ limits
|
|||
memory
|
||||
new
|
||||
optional
|
||||
queue
|
||||
ratio
|
||||
stdexcept
|
||||
tuple
|
||||
|
|
|
@ -26,7 +26,6 @@ memory
|
|||
new
|
||||
numeric
|
||||
optional
|
||||
random
|
||||
ratio
|
||||
stdexcept
|
||||
string
|
||||
|
|
|
@ -21,7 +21,6 @@ limits
|
|||
memory
|
||||
new
|
||||
optional
|
||||
ranges
|
||||
ratio
|
||||
span
|
||||
stdexcept
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
climits
|
||||
cstddef
|
||||
cstdint
|
||||
ratio
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -29,7 +29,6 @@ mutex
|
|||
new
|
||||
optional
|
||||
ratio
|
||||
regex
|
||||
stdexcept
|
||||
string
|
||||
string_view
|
||||
|
|
|
@ -17,7 +17,6 @@ limits
|
|||
memory
|
||||
new
|
||||
ratio
|
||||
scoped_allocator
|
||||
stdexcept
|
||||
tuple
|
||||
type_traits
|
||||
|
|
|
@ -10,6 +10,5 @@ ctime
|
|||
iosfwd
|
||||
limits
|
||||
ratio
|
||||
semaphore
|
||||
type_traits
|
||||
version
|
||||
|
|
|
@ -22,7 +22,6 @@ memory
|
|||
new
|
||||
optional
|
||||
ratio
|
||||
set
|
||||
stdexcept
|
||||
tuple
|
||||
type_traits
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
shared_mutex
|
||||
version
|
||||
|
|
|
@ -22,7 +22,6 @@ memory
|
|||
new
|
||||
optional
|
||||
ratio
|
||||
span
|
||||
stdexcept
|
||||
tuple
|
||||
type_traits
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue