Files
zzet--gortex/internal/resolver/cpp_stdlib_headers_test.go
Andrey Kumanyaev 94b46236f0 feat(resolver): guard c/c++ stdlib headers from include resolution
Add a curated C / C++ / POSIX standard-header allow-list and consult it before
resolving angle includes: a known stdlib header (<vector>, <stdio.h>, …) is
classified external up front and never probed against -I dirs, so it can never
bind to an in-tree file sharing its basename. Angle includes are now resolved
through the -I search path otherwise. Stdlib-header imports surface under a
dedicated resolution-outcome reason, and external-call synthesis treats C-family
stdlib headers as external.
2026-06-24 07:45:54 +02:00

26 lines
708 B
Go

package resolver
import "testing"
func TestIsCppStdlibHeader(t *testing.T) {
stdlib := []string{
"stdio.h", "stdlib.h", "string.h", "stdatomic.h", // C
"vector", "memory", "string", "unordered_map", "filesystem", // C++
"cstdio", "cstring", "cstdint", // <cXXX> wrappers
"unistd.h", "pthread.h", "sys/types.h", "arpa/inet.h", // POSIX
}
for _, h := range stdlib {
if !IsCppStdlibHeader(h) {
t.Errorf("IsCppStdlibHeader(%q) = false, want true", h)
}
}
notStdlib := []string{
"", "proj/api.h", "myheader.h", "vector.h", "foo", "config.h", "string_view.h",
}
for _, h := range notStdlib {
if IsCppStdlibHeader(h) {
t.Errorf("IsCppStdlibHeader(%q) = true, want false", h)
}
}
}