This is an archive of the discontinued LLVM Phabricator instance.

__assume side-effects warning
ClosedPublic

Authored by hfinkel on Jul 16 2014, 8:43 PM.

Details

Reviewers
rsmith
Summary

In MS-compatibility mode, we support the assume builtin. The assume builtin does not evaluate its arguments, and we should issue a warning if __assume is provided with an argument with side effects because these effects will be discarded.

This is similar in spirit to the warnings issued by other compilers (Intel Diagnostic 2261, MS Compiler Warning C4557).

The result currently looks like this:

<stdin>:3:12: warning: the argument to __assume has side effects that will be discarded
  __assume(++i > 2);
           ^~~~~~~
1 warning generated.

Diff Detail

Event Timeline

hfinkel updated this revision to Diff 11555.Jul 16 2014, 8:43 PM
hfinkel retitled this revision from to __assume side-effects warning.
hfinkel updated this object.
hfinkel edited the test plan for this revision. (Show Details)
hfinkel added a reviewer: rsmith.
hfinkel added a subscriber: Unknown Object (MLST).
rsmith accepted this revision.Jul 16 2014, 10:31 PM
rsmith edited edge metadata.

One comment; otherwise, LGTM

lib/Sema/SemaChecking.cpp
1954

This is neither necessary nor sufficient; the relevant thing here is Arg->isInstantiationDependent().

This revision is now accepted and ready to land.Jul 16 2014, 10:31 PM
hfinkel closed this revision.Jul 17 2014, 7:34 AM

r213266, thanks!