Page MenuHomePhabricator

[Clang] Emit mustprogress for infinite C++ loops
Needs ReviewPublic

Authored by atmnpatel on Jan 9 2021, 3:17 PM.

Details

Summary

Currently, clang does not emit the mustprogress loop or function
attribute for loops with non-zero constant conditionals. Based on recent
discussion in D86844 and D86841, it seems that it would be preferable to
emit these attributes to adhere more tightly to the C++ standard as gcc
does.

I will be pushing a patch to add -ffinite-loops and -fno-finite-loops to
clang to provide more control over this momentarily.

Diff Detail

Event Timeline

atmnpatel requested review of this revision.Jan 9 2021, 3:17 PM
atmnpatel created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2021, 3:17 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
atmnpatel updated this revision to Diff 315639.Jan 9 2021, 4:01 PM

while(1) case was mishandled for C++11 onwards, fixed now.

xbolva00 added inline comments.Jan 16 2021, 3:14 AM
clang/lib/CodeGen/CGStmt.cpp
797

Anything non-zero?

clang/test/CodeGen/attr-mustprogress-1.cpp
118

Can you add test for eg. while (42) ?

xbolva00 added inline comments.Jan 16 2021, 3:18 AM
clang/test/CodeGen/attr-mustprogress-1.cpp
32

Test for (; 42; )?