[PATCH] D48464: [x86] Teach the builtin argument range check to allow invalid ranges in dead code.
Chandler Carruth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 21 16:30:54 PDT 2018
chandlerc created this revision.
chandlerc added reviewers: craig.topper, rsmith.
Herald added subscribers: llvm-commits, atanasyan, kbarton, nemanjai, mcrosier, sanjoy.
Herald added a reviewer: javed.absar.
This is important for C++ templates that essentially compute the valid
input in a way that is constant and will cause all the invalid cases to
be dead code that is deleted. Code in the wild actually does this and
GCC also accepts these kinds of patterns so it is important to support
it.
To make this work, we provide a non-error path to diagnose these issues,
and use a default-error warning instead. This keeps the relatively
strict handling but prevents nastiness like SFINAE on these errors. It
also allows us to safely use the system to diagnose this only when it
occurs at runtime (in emitted code).
Entertainingly, this required fixing the syntax in various other ways
for the x86 test because we never bothered to diagnose that the returns
were invalid.
Since debugging these compile failures was super confusing, I've also
improved the diagnostic to actually say what the value was. Most of the
checks I've made ignore this to simplify maintenance, but I've checked
it in a few places to make sure the diagnsotic is working.
Depends on https://reviews.llvm.org/D48462. Without that, we might actually crash some part of
the compiler after bypassing the error here.
Thanks to Richard, Ben Kramer, and especially Craig Topper for all the
help here.
Repository:
rL LLVM
https://reviews.llvm.org/D48464
Files:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-mips-args.c
clang/test/CodeGen/builtins-systemz-vector-error.c
clang/test/CodeGen/builtins-systemz-vector2-error.c
clang/test/CodeGen/builtins-systemz-zvector-error.c
clang/test/CodeGen/builtins-systemz-zvector2-error.c
clang/test/CodeGen/hexagon-check-builtins.c
clang/test/Sema/aarch64-neon-fp16-ranges.c
clang/test/Sema/aarch64-neon-ranges.c
clang/test/Sema/arm-neon-types.c
clang/test/Sema/builtin-object-size.c
clang/test/Sema/builtin-prefetch.c
clang/test/Sema/builtins-arm.c
clang/test/Sema/builtins-arm64.c
clang/test/Sema/builtins-ppc.c
clang/test/Sema/builtins-x86.c
clang/test/Sema/builtins-x86.cpp
clang/test/SemaCXX/neon-vector-types.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48464.152404.patch
Type: text/x-patch
Size: 85374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180621/5ea50a1c/attachment-0001.bin>
More information about the cfe-commits
mailing list