diff options
author | Florian Hahn <flo@fhahn.com> | 2021-02-12 17:45:18 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2021-02-12 19:25:49 +0000 |
commit | 51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f (patch) | |
tree | 3e584387f80bf1f832c93d1c905b566164bb9575 /clang/lib/CodeGen/CodeGenFunction.h | |
parent | 4fc25573089c53804a035080739867ee3b346fdd (diff) | |
download | llvm-51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f.zip llvm-51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f.tar.gz llvm-51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f.tar.bz2 |
[clang] Add -ffinite-loops & -fno-finite-loops options.
This patch adds 2 new options to control when Clang adds `mustprogress`:
1. -ffinite-loops: assume all loops are finite; mustprogress is added
to all loops, regardless of the selected language standard.
2. -fno-finite-loops: assume no loop is finite; mustprogress is not
added to any loop or function. We could add mustprogress to
functions without loops, but we would have to detect that in Clang,
which is probably not worth it.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D96419
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index dd77d70..ff98751 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -507,12 +507,26 @@ public: /// True if the C++ Standard Requires Progress. bool CPlusPlusWithProgress() { + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Never) + return false; + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Never) + return false; + return getLangOpts().CPlusPlus11 || getLangOpts().CPlusPlus14 || getLangOpts().CPlusPlus17 || getLangOpts().CPlusPlus20; } /// True if the C Standard Requires Progress. bool CWithProgress() { + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Always) + return true; + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Never) + return false; + return getLangOpts().C11 || getLangOpts().C17 || getLangOpts().C2x; } |