Naggy now does lowlighting of excluded code!

Naggy, the AVR Studio extension I wrote that provided live compiler diagnostics, now supports visually showing conditionally excluded code, again courtesy Clang. You can download the latest version here.

Most of the Clang integration code had to be rewritten for this though, as the “black box” API provided by Clang didn’t expose enough details to make this work. It took some time to get familiar with that, and I still don’t think I’ve understood Clang’s idea of object ownership completely, but boy, was it fun! I basically register a custom PPCallback with the Preprocessor and then listen to the entry/exclusion of conditional preprocessor directives. What made life difficult was that the callbacks weren’t fired by Clang
in any meaningful order – you’d sometimes get a callback for #endif
before the #if callback, based on whether the #if evaluated to true or
false. I eventually ended up just recording the source location and entered/not
entered information in the callback. When it’s time to show the excluded code, I calculate the actual
excluded blocks of code by sorting the source locations and then pairing them.

I had to change Clang code to have the callback determine whether a particular conditional preprocessor block was entered or not. I also discovered and fixed a bug in the codebase, and I’m hoping to push these changes back into the Clang codebase.

Now that the lowlighting code uses the low level API, I couldn’t have the diagnostics finding code use the higher level one – that would mean that the source file would get processed twice, once for diag finding and once for lowlighting. So there were some changes there too to unify both of these clients to share the Clang instance and have code processed only once. Hopefully I didn’t break anything that worked earlier 🙂

As usual, the source code is up at, and you can download the extension itself at


2 thoughts on “Naggy now does lowlighting of excluded code!

  1. Hello Senthil Kumar!

    The Naggy extension the for AVR STUDIO 5 its nice and very helpful!!!

    I have questions. Why naggy cant see all the definitions and produce an error? What i mean is that when i make a new xmega project in the sysclk_init() function naggy cant see the definitions that are configured on conf_clock.h header and its marking them red. Well the problem its not limited on that and Naggy marks many code lines red because it cant see the definitions (use of undeclared indentifier ‘XXX’). The last feature of lowlighting of excluded code its very help full and what i was searching from migration from AVR32Studio to AVR STUDIO 5!
    Sorry for my bad english i hope you understand me… AVRFREAKS id > DieCore e@mail diecore64

  2. Thanks a mill for a great extension.

    I get a error on wdt_enable(WDTO_15MS); “Error 2 1643 : unknown register name ‘r0’ in asm”

    I would like to request a feature where one can right click the error / warning line and select a “Disable this error / warning” instead of editing the BlacklistedDiagnostics.txt file.

    If possible disable only individual lines.
    It could be that a error / warning is acceptable / desirable in one or more lines, but must still be checked in the rest of the project.

    Keep up the good work.

Leave a Reply

Your email address will not be published. Required fields are marked *