llvm-project/clang/lib
Clement Courbet 9d432e0d14 [WIP][Sema] Improve static_assert diagnostics for type traits.
Summary:
In our codebase, `static_assert(std::some_type_trait<Ts...>::value, "msg")`
(where `some_type_trait` is an std type_trait and `Ts...` is the
appropriate template parameters) account for 11.2% of the `static_assert`s.

In these cases, the `Ts` are typically not spelled out explicitly, e.g.
`static_assert(std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value, "message");`

The diagnostic when the assert fails is typically not very useful, e.g.
`static_assert failed due to requirement 'std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value' "message"`

This change makes the diagnostic spell out the types explicitly , e.g.
`static_assert failed due to requirement 'std::is_same<int, float>::value' "message"`

See tests for more examples.

After this is submitted, I intend to handle
`static_assert(!std::some_type_trait<Ts...>::value, "msg")`,
which is another 6.6% of static_asserts.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54903

llvm-svn: 348239
2018-12-04 07:59:57 +00:00
..
ARCMigrate Fix clang -Wimplicit-fallthrough warnings across llvm, NFC 2018-11-01 19:54:45 +00:00
AST [WIP][Sema] Improve static_assert diagnostics for type traits. 2018-12-04 07:59:57 +00:00
ASTMatchers Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher." 2018-11-22 14:26:33 +00:00
Analysis Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
Basic [Basic] Move DiagnosticsEngine::dump from .h to .cpp 2018-12-01 01:43:05 +00:00
CodeGen Remove unnecessary include. 2018-12-04 04:53:18 +00:00
CrossTU [CrossTU] Fix handling of Cross Translation Unit directory path 2017-10-27 12:53:37 +00:00
Driver [Sema] Provide -fvisibility-global-new-delete-hidden option 2018-12-04 03:25:25 +00:00
Edit [Fixed Point Arithmetic] Fixed Point to Boolean Cast 2018-10-23 17:55:35 +00:00
Format [clang-format] Do not treat asm clobber [ as ObjCExpr, refined 2018-11-22 14:49:55 +00:00
Frontend [Sema] Provide -fvisibility-global-new-delete-hidden option 2018-12-04 03:25:25 +00:00
FrontendTool Sink BuryPointer from Clang into LLVM for reuse there 2018-11-17 18:04:13 +00:00
Headers [CMake] Store path to vendor-specific headers in clang-headers target property 2018-12-03 10:34:25 +00:00
Index [Index] Expose USR generation for types 2018-11-26 15:24:48 +00:00
Lex Fix combining pragma __debug dump & parser_crash with -E 2018-11-15 03:04:21 +00:00
Parse [CodeComplete] Cleanup access checking in code completion 2018-12-03 13:29:17 +00:00
Rewrite Fix clang -Wimplicit-fallthrough warnings across llvm, NFC 2018-11-01 19:54:45 +00:00
Sema [WIP][Sema] Improve static_assert diagnostics for type traits. 2018-12-04 07:59:57 +00:00
Serialization [Serialization][NFC] Remove pointless "+ 0" in ASTReader 2018-12-03 16:17:45 +00:00
StaticAnalyzer [analyzer] MoveChecker: Add more common state resetting methods. 2018-12-04 03:38:08 +00:00
Tooling clang::tooling::Diagnostic: Don't store offset in the scratch space. 2018-11-21 01:08:46 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00