llvm-project/clang/docs
Eric Fiselier 1af6c114cc Add `__reference_binds_to_temporary` trait for checking safe reference initialization.
Summary:
The STL types `std::pair` and `std::tuple` can both store reference types. However their constructors cannot adequately check if the initialization of reference types is safe.  For example:

```
std::tuple<std::tuple<int> const&> t = 42;
// The stored reference is already dangling.
```

Libc++ has a best effort attempts in tuple to diagnose this, but they're not able to handle all valid cases (If I'm not mistaken). For example initialization of a reference from the result of a class's conversion operator.  Libc++ would benefit from having a builtin traits which can provide a much better implementation.

This patch introduce the `__reference_binds_to_temporary(T, U)` trait  that determines whether a reference of type `T` bound to an expression of type `U` would bind to a materialized temporary object.

Note that the trait simply returns false if `T` is not a reference type instead of reporting it as an error.

```
static_assert(__is_constructible(int const&, long));
static_assert(__reference_binds_to_temporary(int const&, long));
```


Reviewers: majnemer, rsmith

Reviewed By: rsmith

Subscribers: compnerd, cfe-commits

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

llvm-svn: 322334
2018-01-12 00:09:37 +00:00
..
CommandGuide Driver: Remove support for -fobjc-gc* 2016-12-07 00:31:10 +00:00
analyzer [analyzer] Document the issue hash debugging facility 2017-11-13 11:13:02 +00:00
tools [clang-format] Sort using declarations by splitting on '::' 2017-11-09 15:41:23 +00:00
AddressSanitizer.rst [docs] Update LeakSanitizer documentation to reflect OS X support 2017-09-13 19:40:10 +00:00
AttributeReference.rst Adding a title to appease the sphinx build bot. 2015-06-23 17:31:30 +00:00
AutomaticReferenceCounting.rst docs: update docs for objc_storeStrong behaviour 2017-02-11 17:24:09 +00:00
Block-ABI-Apple.rst Typo fix: appropo -> apropos. NFC. 2017-06-19 20:08:20 +00:00
Block-ABI-Apple.txt
BlockLanguageSpec.rst
CMakeLists.txt docs: Fix Sphinx detection with out-of-tree builds 2017-05-09 01:42:33 +00:00
ClangCheck.rst [clang docs] Minor fix in ClangCheck.rst 2016-11-14 17:31:24 +00:00
ClangCommandLineReference.rst [Docs] Re-generate command line documentation, primarily to get the icelake feature command line options in, but there were a couple other changes too. 2018-01-03 18:29:12 +00:00
ClangFormat.rst [Docs] Update list of languages clang-format can format 2017-11-22 10:47:35 +00:00
ClangFormatStyleOptions.rst [clang-format] Add option to group multiple #include blocks when sorting includes 2017-11-27 13:23:45 +00:00
ClangPlugins.rst Removing more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15195/steps/docs-clang-html/logs/stdio). 2016-07-14 14:07:37 +00:00
ClangTools.rst Fixed a link. 2015-11-04 19:42:17 +00:00
ControlFlowIntegrity.rst [CFI] Add CFI-icall pointer type generalization 2017-10-31 22:39:44 +00:00
ControlFlowIntegrityDesign.rst Fix broken links to the Itanium CXX ABI 2017-09-12 00:21:17 +00:00
CrossCompilation.rst [docs] Use x86_64 and i386 instead of x86 as arch for triples. 2016-12-05 22:52:20 +00:00
DataFlowSanitizer.rst
DataFlowSanitizerDesign.rst
DiagnosticsReference.rst [www] Regenerate diagnostics reference. 2017-10-26 21:06:52 +00:00
DriverArchitecture.png
DriverInternals.rst Driver: Replace a couple of out of date terms in the docs 2015-07-03 08:03:43 +00:00
ExternalClangExamples.rst Add LibreOffice Clang plugin to ExternalClangExamples.rst 2017-03-22 08:45:49 +00:00
FAQ.rst
HardwareAssistedAddressSanitizerDesign.rst [hwasan] update the design doc 2017-12-18 21:40:07 +00:00
HowToSetupToolingForLLVM.rst Fixed a typo (compilation_commands.json --> compile_commands.json). 2016-08-19 13:36:31 +00:00
InternalsManual.rst Fix typos in documentation 2017-10-09 23:45:20 +00:00
IntroductionToTheClangAST.rst
ItaniumMangleAbiTags.rst NFC fix documentation build by rL263015 2016-03-09 19:39:16 +00:00
JSONCompilationDatabase.rst [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found. 2017-11-09 10:37:39 +00:00
LTOVisibility.rst docs: Use the term "whole-program devirtualization" instead of "virtual function call optimization". 2017-04-10 23:54:28 +00:00
LanguageExtensions.rst Add `__reference_binds_to_temporary` trait for checking safe reference initialization. 2018-01-12 00:09:37 +00:00
LeakSanitizer.rst [docs] Update LeakSanitizer documentation to reflect OS X support 2017-09-13 19:40:10 +00:00
LibASTMatchers.rst Typo fix in AST matcher documentation: s/aribtrary/arbitrary/ 2016-12-31 01:04:02 +00:00
LibASTMatchersReference.html Add the hasDefinition() AST matcher to match class declarations that also have a definition. 2017-11-29 21:21:51 +00:00
LibASTMatchersTutorial.rst [clang] Minor fix to libASTMatcherTutorial 2016-12-30 20:49:44 +00:00
LibFormat.rst clang-format - Also reference the list of style option of clang-format in Libformat 2017-06-26 03:19:05 +00:00
LibTooling.rst
MSVCCompatibility.rst Update MSVC compat docs about debug info 2016-12-14 21:34:19 +00:00
Makefile.sphinx docs: Clarify that cfi-unrelated-cast is based on lifetime. 2016-02-01 18:55:50 +00:00
MemorySanitizer.rst Fix a typo 2017-06-26 02:45:08 +00:00
Modules.rst [Modules] Change private modules rules and warnings 2017-12-22 02:53:30 +00:00
ObjectiveCLiterals.rst Fix typo. NFC. 2015-06-27 19:04:55 +00:00
OpenMPSupport.rst [OPENMP] Current status of OpenMP support. 2018-01-08 19:02:51 +00:00
PCHInternals.rst Removing a few more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15197/steps/docs-clang-html/logs/stdio). 2016-07-14 15:32:11 +00:00
PCHLayout.graffle
PCHLayout.png
PTHInternals.rst
RAVFrontendAction.rst docs: Remove references to the long-defunct LLVM_USED_LIBS 2015-11-26 19:52:24 +00:00
README.txt
RefactoringEngine.rst Fix small nits in clang-refactor doc. 2017-10-10 09:00:56 +00:00
ReleaseNotes.rst Document attribute target multiversioning. 2018-01-08 23:36:29 +00:00
SafeStack.rst docs: Document how safestack handles setjmp and exceptions. 2016-05-24 23:38:02 +00:00
SanitizerCoverage.rst docs: don't say that data flow tracing interface is unstable 2017-08-31 11:02:44 +00:00
SanitizerSpecialCaseList.rst Allow specifying sanitizers in blacklists 2017-09-25 22:11:12 +00:00
SanitizerStats.rst Introduce -fsanitize-stats flag. 2016-01-16 00:31:22 +00:00
SourceBasedCodeCoverage.rst [docs] Coverage: Improve the wording a bit 2017-06-19 21:26:04 +00:00
ThinLTO.rst CachePruning: Allow limiting the number of files in the cache directory. 2017-11-22 18:27:31 +00:00
ThreadSafetyAnalysis.rst Correct the attribute spelling for guarded_var and pt_guarded_var. 2017-05-08 12:39:17 +00:00
ThreadSanitizer.rst [docs] Update the TSan and MSan docs to refer to the new no_sanitize attribute 2016-10-27 21:38:44 +00:00
Toolchain.rst Fix broken links to the Itanium CXX ABI 2017-09-12 00:21:17 +00:00
Tooling.rst
UndefinedBehaviorSanitizer.rst [ubsan] Diagnose noreturn functions which return 2017-12-21 00:10:25 +00:00
UsersManual.rst UserManual: Update with the latest clang-cl flags 2018-01-03 13:20:25 +00:00
conf.py Update docs version and clear release notes for 7.0.0 2018-01-03 15:49:39 +00:00
doxygen-mainpage.dox [docs] Add missing file 2016-03-03 10:44:10 +00:00
doxygen.cfg.in PR19260: Teach doxygen to spell correctly the include paths. 2017-04-20 08:57:41 +00:00
index.rst [OPENMP] Current status of OpenMP support. 2018-01-08 19:02:51 +00:00
make.bat

README.txt

See llvm/docs/README.txt