[LLVMbugs] [Bug 12698] New: HTMLRewrite generates bogus information for macros

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Apr 29 17:33:44 PDT 2012


             Bug #: 12698
           Summary: HTMLRewrite generates bogus information for macros
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: oneill+llvmbugs at cs.hmc.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 8475
  --> http://llvm.org/bugs/attachment.cgi?id=8475
Sample problematic file

tools/clang/lib/Rewrite/HTMLRewrite.cpp contains the following comment:

/// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
/// information about keywords, macro expansions etc.  This uses the macro
/// table state from the end of the file, so it won't be perfectly perfect,
/// but it will be reasonably close.

Unfortunately, for some uses of macros, "reasonably close" is actually
"completely and utterly wrong".  Generally speaking, I think it's much better
to say nothing than say something wrong with no indication that it's wrong.

In particular, if the code uses #undef or has macro args that shadow
preexisting macros (using a macro argument max when max already exists as a
macro), the output will be misleadingly wrong.


run clang -cc1 -emit-html on

#define FOO aaa

int FOO () { return 0; }

#define BAR(FOO) FOO

#undef FOO
#define FOO zzz

This code claim the function defined is zzz, not aaa, and that in BAR(FOO), the
body will expand to zzz, which it won't.

I understand that this was written as a quick hack, but people look to this
code for how to do things.  Wouldn't it be more sensible to actually use the
AST to find the macro expansions, since that would actually be correct...?

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list