llvm-project/clang/docs
Richard Smith 72315d02c4 Treat `std::move`, `forward`, etc. as builtins.
This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc30901096,
  a571f82a50,
  64c045e25b, and
  de6ddaeef3,
and reverts aa643f455a.
This change also includes a workaround for users using libc++ 3.1 and
earlier (!!), as apparently happens on AIX, where std::move sometimes
returns by value.

Reviewed By: aaron.ballman

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

Revert "Fixup D123950 to address revert of D123345"

This reverts commit aa643f455a.
2022-04-20 17:58:31 -07:00
..
CommandGuide Treat `std::move`, `forward`, etc. as builtins. 2022-04-20 17:58:31 -07:00
DataFlowAnalysisIntroImages [clang][docs][dataflow] Added an introduction to dataflow analysis 2021-12-06 12:16:35 +01:00
analyzer [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file 2022-03-22 10:28:42 +08:00
tools [analyzer] Expose Taint.h to plugins 2022-04-19 16:55:01 +02:00
APINotes.rst
AddressSanitizer.rst [asan] Add support for disable_sanitizer_instrumentation attribute 2022-02-18 09:51:54 +01:00
AutomaticReferenceCounting.rst [clang] Document objc_unsafeClaimAutoreleasedReturnValue. 2022-02-08 14:30:39 -08:00
Block-ABI-Apple.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
BlockLanguageSpec.rst
CMakeLists.txt
ClangCheck.rst
ClangCommandLineReference.rst [Clang][Docs] Update information on the new driver now that it's default 2022-04-18 15:05:09 -04:00
ClangFormat.rst [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst. 2022-03-23 13:17:50 +01:00
ClangFormatStyleOptions.rst [clang-format][docs] Fix incorrect 'clang-format 11' option markers 2022-04-06 18:38:30 -07:00
ClangFormattedStatus.rst [clang-format] NFC update LLVM overall clang-formatted status 2022-03-06 20:03:27 +00:00
ClangLinkerWrapper.rst [Clang][Docs] Add documention for new OpenMP offloading driver 2022-02-03 13:09:49 -05:00
ClangNvlinkWrapper.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
ClangOffloadBundler.rst [clang][NFC] Fix Typo 2022-01-28 11:55:46 -08:00
ClangOffloadWrapper.rst [Doc] Fix wrong indentation 2022-01-19 11:15:31 +00:00
ClangPlugins.rst [docs] Add note about interaction between clang plugins and -clear-ast-before-backend 2022-02-28 12:53:09 -08:00
ClangStaticAnalyzer.rst
ClangTools.rst [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
ClangTransformerTutorial.rst Add a clang-transformer tutorial 2021-11-17 13:40:46 +00:00
ConstantInterpreter.rst
ControlFlowIntegrity.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
ControlFlowIntegrityDesign.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
CrossCompilation.rst
DataFlowAnalysisIntro.md [analyzer][NFC] Merge similar conditional paths 2022-03-07 22:05:27 +05:30
DataFlowSanitizer.rst Update all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS 2022-02-10 15:05:23 -05:00
DataFlowSanitizerDesign.rst [clang] Fix typos in documentation (NFC) 2021-08-21 12:17:58 -07:00
DriverArchitecture.png
DriverInternals.rst
ExternalClangExamples.rst
FAQ.rst
HLSLSupport.rst [Clang] [Docs] Add HLSLSupport page 2022-04-08 12:17:45 -05:00
HardwareAssistedAddressSanitizerDesign.rst [HWASan] Mention x86_64 aliasing mode in design doc. 2021-03-25 14:22:20 -07:00
HowToSetupToolingForLLVM.rst [tooling] Explain how to create a compilation database on Windows [NFC] 2022-03-04 13:06:08 -07:00
InternalsManual.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
IntroductionToTheClangAST.rst [clang] Fix typos in documentation (NFC) 2021-08-21 12:17:58 -07:00
ItaniumMangleAbiTags.rst
JSONCompilationDatabase.rst [docs] [clang] Small documentation change for compilation databases 2022-01-22 17:30:34 -08:00
LTOVisibility.rst
LanguageExtensions.rst [Clang] Implement __builtin_source_location. 2022-03-28 18:29:02 -04:00
LeakSanitizer.rst [lsan][docs] Clarify supported platforms 2021-04-21 10:27:55 -07:00
LibASTImporter.rst
LibASTMatchers.rst
LibASTMatchersReference.html [ASTMatchers] Expand isInline matcher to VarDecl 2022-02-23 08:34:00 +00:00
LibASTMatchersTutorial.rst [docs] Fix linking issues in LibASTMatchers tutorial 2021-07-05 12:11:25 +03:00
LibFormat.rst [NFC] Inclusive language: Remove instances of master in URLs 2021-11-05 08:48:41 -05:00
LibTooling.rst [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
MSVCCompatibility.rst
MatrixTypes.rst [Matrix] Add missing newline to appease sphinx. 2021-03-12 09:33:36 +00:00
MemorySanitizer.rst [msan] Add link to the lifetime definition 2022-03-29 14:42:36 -07:00
MisExpect.rst [misexpect] Re-implement MisExpect Diagnostics 2022-04-19 21:23:48 +00:00
Modules.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
ObjectiveCLiterals.rst
OffloadingDesign.rst [Clang][Docs] Update information on the new driver now that it's default 2022-04-18 15:05:09 -04:00
OpenCLSupport.rst [Docs][OpenCL] Update OpenCL 3.0 status in docs. 2022-02-16 12:32:20 +00:00
OpenMPSupport.rst [Clang][Docs] Update information on the new driver now that it's default 2022-04-18 15:05:09 -04:00
PCHInternals.rst
PCHLayout.graffle
PCHLayout.png
RAVFrontendAction.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
README.txt
RefactoringEngine.rst
ReleaseNotes.rst Treat `std::move`, `forward`, etc. as builtins. 2022-04-20 17:58:31 -07:00
SYCLSupport.rst [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL 2021-05-18 10:27:35 +03:00
SafeStack.rst
SanitizerCoverage.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
SanitizerSpecialCaseList.rst [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist= 2021-05-04 10:24:00 -04:00
SanitizerStats.rst
ShadowCallStack.rst
SourceBasedCodeCoverage.rst Coverage: Document how to collect a profile without a filesystem 2021-04-22 11:29:39 -07:00
ThinLTO.rst [clang] Fix sentence in the usage section of ThinLTO docs. 2021-09-30 07:26:19 +05:30
ThreadSafetyAnalysis.rst [clang][docs] Inclusive language: remove use of sanity check in option description 2021-11-30 15:07:43 -05:00
ThreadSanitizer.rst [tsan] Add support for disable_sanitizer_instrumentation attribute 2021-08-23 12:38:33 +02:00
Toolchain.rst Update all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS 2022-02-10 15:05:23 -05:00
Tooling.rst
UndefinedBehaviorSanitizer.rst Improve UBSan documentation 2021-08-02 15:10:21 -07:00
UsersManual.rst [docs] Remove outdated -fexperimental-new-pass-manager for profile data remapping support 2022-04-11 13:49:06 -07:00
conf.py [docs] Remove hard-coded version numbers from sphinx configs 2022-02-01 23:14:12 -08:00
doxygen-mainpage.dox
doxygen.cfg.in [NFC] Inclusive Language: change master to main for .chm files 2021-11-08 08:23:04 -06:00
index.rst [misexpect] Re-implement MisExpect Diagnostics 2022-04-19 21:23:48 +00:00
make.bat

README.txt

See llvm/docs/README.txt