This is an archive of the discontinued LLVM Phabricator instance.

Fix PR20069: bad loop pragma arguments crash FE
ClosedPublic

Authored by meheff on Jun 18 2014, 11:10 AM.

Details

Summary

This patch fixes a crash when handling malformed arguments to loop pragmas such as: "#pragma clang loop vectorize(()". Essentially any argument which is not an identifier or constant resulted in a crash. This patch also changes a couple of the error messages which weren't quite correct. New behavior with this patch vs old behavior:

#pragma clang loop vectorize(1)
OLD: error: missing keyword; expected 'enable' or 'disable'
NEW: error: invalid argument; expected 'enable' or 'disable'

#pragma clang loop vectorize()
OLD: error: expected ')'
NEW: error: missing argument to loop pragma 'vectorize'

#pragma clang loop vectorize_width(bad)
OLD: error: missing value; expected a positive integer value
NEW: error: invalid argument; expected a positive integer value

#pragma clang loop vectorize(bad)
OLD: invalid keyword 'bad'; expected 'enable' or 'disable'
NEW: error: invalid argument; expected 'enable' or 'disable'

In the last example above, the old behavior isn't incorrect. I made the change as it simplified the code a bit and made the message consistent regardless of what the argument is (rather than just printing the argument if it is an identifier). Happy to change it back if anyone thinks it's a step backwards.

Diff Detail

Event Timeline

meheff updated this revision to Diff 10579.Jun 18 2014, 11:10 AM
meheff retitled this revision from to Fix PR20069: bad loop pragma arguments crash FE.
meheff updated this object.
meheff edited the test plan for this revision. (Show Details)
meheff added reviewers: TylerNowicki, aaron.ballman.
meheff added a subscriber: Unknown Object (MLST).
eliben accepted this revision.Jun 19 2014, 11:22 AM
eliben edited edge metadata.
This revision is now accepted and ready to land.Jun 19 2014, 11:22 AM
meheff closed this revision.Jun 19 2014, 12:59 PM