aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorcor3ntin <corentinjabot@gmail.com>2024-05-03 14:10:54 +0200
committerGitHub <noreply@github.com>2024-05-03 14:10:54 +0200
commit642117105d4f7944b7944f9b2a6ba9993fb68ed9 (patch)
treecc27818b268fe0526aab031f97098843e5fc79ef /clang/lib/CodeGen/CodeGenFunction.cpp
parent5850f6ba9b2c14d8457c6e8455483a20b2bf3636 (diff)
downloadllvm-642117105d4f7944b7944f9b2a6ba9993fb68ed9.zip
llvm-642117105d4f7944b7944f9b2a6ba9993fb68ed9.tar.gz
llvm-642117105d4f7944b7944f9b2a6ba9993fb68ed9.tar.bz2
[Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (#90066)
https://wg21.link/P2809R3 This is applied as a DR to C++11 (C++98 did not guarantee forward progress and is left untouched) As an extension (and to preserve existing behavior in C), we consider all controlling expression that can be constant folded in the front end, not just standard constant expressions.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 87766a7..546beae 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1471,6 +1471,8 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
// Ensure that the function adheres to the forward progress guarantee, which
// is required by certain optimizations.
+ // In C++11 and up, the attribute will be removed if the body contains a
+ // trivial empty loop.
if (checkIfFunctionMustProgress())
CurFn->addFnAttr(llvm::Attribute::MustProgress);