[patch] Refactor the Used flag logic (and a small bug fix)

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Oct 23 09:10:59 PDT 2013


Hi Richard,

This is mostly an implementation of your suggestion on how to handle
the Used flag.

At first I thought the best candidate for holding the flag was the
first decl. Doing that would remove the need the propagate the flag to
newer decls. The problem is that there are cases where we want to know
if a particular decl has the UsedAttr, so we cannot just add a
UsedAttr to the first decl.

The next best candidate was the last decl. This requires merging the
flag, but that is not too hard.

Yet another option would be checking the first decl for the flag and
the last one for the attribute. There is a link from the first to the
last, so going from one to the other is fairly fast.

The patch also
* Fixes a small bug: We would consider func unused in

static void func();
void bar() { void func() __attribute__((used)); }
static void func() {}

* Removes the argument to setIsUsed. Given its meaning, it does'n make
sense to clear the flag.

* Removes the special case in MarkFunctionReferenced.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: text/x-patch
Size: 9024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131023/3e28142c/attachment.bin>


More information about the cfe-commits mailing list