This is an archive of the discontinued LLVM Phabricator instance.

Add a warning for builtin_return_address/frame_address with > 0 argument
ClosedPublic

Authored by jstenglein on Mar 6 2020, 12:39 PM.

Details

Summary

Clang is missing a warning for builtin_return_address/builtin_frame_address called with > 0 argument. Gcc provides a warning for this via -Wframe-address:

https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html

As calling these functions with argument > 0 has caused several crashes for us, we would like to have the same warning as gcc here. This diff adds the warning and makes it part of -Wmost.

Diff Detail

Event Timeline

jstenglein created this revision.Mar 6 2020, 12:39 PM

Any reason to not put this in -Wall like GCC? I'm not terribly knowledgeable about the intended guidance for adding to Wmost, so if you can clarify this decision I'd be grateful. Otherwise I think this patch looks fine.

Any reason to not put this in -Wall like GCC? I'm not terribly knowledgeable about the intended guidance for adding to Wmost, so if you can clarify this decision I'd be grateful. Otherwise I think this patch looks fine.

Thanks for the comments. It is already part of -Wall since I put it in -Wmost and -Wall includes -Wmost:
def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, MisleadingIndentation]>;

Any reason to not put this in -Wall like GCC? I'm not terribly knowledgeable about the intended guidance for adding to Wmost, so if you can clarify this decision I'd be grateful. Otherwise I think this patch looks fine.

Thanks for the comments. It is already part of -Wall since I put it in -Wmost and -Wall includes -Wmost:
def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, MisleadingIndentation]>;

Right, I know. I'm wondering about what made you choose most? I dont know our rules for warning groups, so hopefully someone else can comment.

Any reason to not put this in -Wall like GCC? I'm not terribly knowledgeable about the intended guidance for adding to Wmost, so if you can clarify this decision I'd be grateful. Otherwise I think this patch looks fine.

Thanks for the comments. It is already part of -Wall since I put it in -Wmost and -Wall includes -Wmost:
def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, MisleadingIndentation]>;

Right, I know. I'm wondering about what made you choose most? I dont know our rules for warning groups, so hopefully someone else can comment.

I chose Most to get the warning included in -Wall - if there is a better placement let me know.

lebedev.ri resigned from this revision.Mar 9 2020, 6:27 AM
lebedev.ri added a reviewer: aaron.ballman.

This seems reasonable to me but i'll defer to other reviewers.

erichkeane accepted this revision.Mar 9 2020, 8:18 AM

I did a bit of research and I don't think i know of anything better than 'most' here, and noone else had an opinion at the end of last week so I'll take that silence as consent. Approved!

This revision is now accepted and ready to land.Mar 9 2020, 8:18 AM

I did a bit of research and I don't think i know of anything better than 'most' here, and noone else had an opinion at the end of last week so I'll take that silence as consent. Approved!

Thanks... could you please commit the patch as I don't have commit permission yet? Also I saw a build-bot failure but it looks to be in clang-format on the test file which doesn't make sense.

This revision was automatically updated to reflect the committed changes.