summaryrefslogtreecommitdiffstats
path: root/include/clang/Frontend/CodeGenOptions.def
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-01-04 13:40:34 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-01-04 13:40:34 +0000
commit8fca6cf5969b00357ecf6b33a008f2633c5f0b93 (patch)
tree1d987390e827995cfd8ad28ddc88d2e53a95a327 /include/clang/Frontend/CodeGenOptions.def
parent8bd2b99f9b7a5a83534a4bbf73e2db4f608055c2 (diff)
Add -f[no-]strict-return flag that can be used to avoid undefined behaviour
in non-void functions that fall off at the end without returning a value when compiling C++. Clang uses the new compiler flag to determine when it should treat control flow paths that fall off the end of a non-void function as unreachable. If -fno-strict-return is on, the code generator emits the ureachable and trap IR only when the function returns either a record type with a non-trivial destructor or another non-trivially copyable type. The primary goal of this flag is to avoid treating falling off the end of a non-void function as undefined behaviour. The burden of undefined behaviour is placed on the caller instead: if the caller ignores the returned value then the undefined behaviour is avoided. This kind of behaviour is useful in several cases, e.g. when compiling C code in C++ mode. rdar://13102603 Differential Revision: https://reviews.llvm.org/D27163 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290960 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend/CodeGenOptions.def')
-rw-r--r--include/clang/Frontend/CodeGenOptions.def4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def
index 1f0c83b5bf..54c9f81265 100644
--- a/include/clang/Frontend/CodeGenOptions.def
+++ b/include/clang/Frontend/CodeGenOptions.def
@@ -251,6 +251,10 @@ CODEGENOPT(DiagnosticsWithHotness, 1, 0)
/// Whether copy relocations support is available when building as PIE.
CODEGENOPT(PIECopyRelocations, 1, 0)
+/// Whether we should use the undefined behaviour optimization for control flow
+/// paths that reach the end of a function without executing a required return.
+CODEGENOPT(StrictReturn, 1, 1)
+
#undef CODEGENOPT
#undef ENUM_CODEGENOPT
#undef VALUE_CODEGENOPT