[PATCH] Prevent clang from throwing the diagnostics twice.

Aaron Ballman aaron at aaronballman.com
Fri Nov 15 08:31:21 PST 2013


On Fri, Nov 15, 2013 at 11:19 AM, Umesh Kalappa
<umesh.kalappa0 at gmail.com> wrote:
> Hi Aaron,
>
>>>Why is getLastArgIntValue being called twice in the first place?
>
> It has been called from the getOptimizationLevel() ,which in turn called by
> methods like ParseCodeGenArgs() and ParseLangArgs(),
>
> where method getOptimizationLevel() register the "invalid integral value"
> diagnostics in the diagnostics engine twice ,since it was called twice.
>
> So i added the flag to check if the diagnostics is already registered for a
> specific argument then don't add again and for first time set the flag.
>
> Any suggestion are welcome .

As Chad pointed, it's likely that this requires a non-trivial
refactoring. I don't have particularly bright ideas on solving it, but
I'm uncomfortable adding the flag at the arg level because it kind of
encourages lazy design when handling args. Perhaps looking into ways
the code could be refactored so that getOptimizationLevel() is only
called once (and perhaps the results get cached somewhere) would be a
good approach.

~Aaron



More information about the cfe-commits mailing list