alwayszero function attribute for gcc

RESOLVED INACTIVE

Status

defect
RESOLVED INACTIVE
10 years ago
5 months ago

People

(Reporter: taras.mozilla, Assigned: ehren.m)

Tracking

({student-project})

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments)

Reporter

Description

10 years ago
In mozilla we have a lot of functions that always return NS_OK(0). This means that callers of such functions usually have unneeded error checking.

nsresult rv = call();
if (NS_FAILED(rv)....)  <-- gcc should be able to optimize this away if it knows that value of call() is always zero

For reference see gcc function attributes: pure, const. and Gcc variable attribute nonnull(I don't see that one in the docs anymore, is it gone?).
Reporter

Comment 1

10 years ago
alternatively/additionally we should do static analysis to ensure that always zerofunctions
a) only ever return 0
b) never have their return value checked
Assignee: nobody → ehren.m
Status: NEW → ASSIGNED
Assignee

Comment 2

10 years ago
This has a problem with being able to print off the class location of a method with a misapplied attribute. Being a ripoff of outparams.js, there may still be some unnecessary code as well.
Assignee

Comment 3

10 years ago
there are some indenting issues here, particularly when a declaration is broken over several lines.
Assignee

Comment 5

10 years ago
compile with make CC=/path/to/plugin-enabled/gcc (requires plugin framework from GCC 4.5)
Assignee

Updated

10 years ago
Attachment #416042 - Attachment mime type: text/x-csrc → text/plain
Assignee

Updated

10 years ago
Attachment #416043 - Attachment mime type: application/octet-stream → text/plain
Assignee

Comment 6

10 years ago
Not sure if all of this is ready for review yet. For one thing when FIND_NEW_FUNCTIONS = true, a whole lot of output will be printed during static analysis builds. There's also a lot more patching to be done (likely with Pork).

Updated

Last year
Product: Core → Firefox Build System
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.