This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Emit mustprogress for infinite C++ loops
AbandonedPublic

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; )?

fhahn requested changes to this revision.Jul 5 2021, 3:12 AM

I think this has been addressed by some commits a while ago. Marking as changes requested to clear up review queue. Please feel free to update the patch in case there’s anything I missed.

This revision now requires changes to proceed.Jul 5 2021, 3:12 AM
atmnpatel abandoned this revision.Sep 22 2021, 7:43 AM