[LLVMbugs] [Bug 18366] New: Codegen: DeclPrinter.cpp: wrong struct declaration

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 3 05:13:13 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18366

            Bug ID: 18366
           Summary: Codegen: DeclPrinter.cpp: wrong struct declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Nemanicka at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Source function (FunctionDecl * foo ) :

void foo()
{

struct STR1 {
       int x;
    } a,b;     <- Source declaration

struct STR1 c;

 int y =2;
}

After making smth like 
"FunctionDecl * foo1 = foo"
"Rewriter.insertText(..., (AsText)foo1)"                       
Output function

void foo1() {
    struct STR1 {
        int x;
    } struct a, b; <- extra "struct" declaration!
    struct STR1 c;
    int y = 2;
}

DeclPrinter.cpp:
In function void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent):

for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
       D != DEnd; ++D) 
{

std::cout << (*D)->getDeclKindName() << std::endl; <- INSERTION

// The next bits of code handles stuff like "struct {int x;} a,b"; we're
    // forced to merge the declarations because there's no other way to
    // refer to the struct in question.  This limited merging is safe without
    // a bunch of other checks because it only merges declarations directly
    // referring to the tag, not typedefs.
    //
    // Check whether the current declaration should be grouped with a previous
    // unnamed struct.
/*
...code...
*/
}

OUTPUT:
1. Field
...
...
...
N. Field

1. Does this block of code handle only field?

2. How to detect "a,b" struct declarations?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140103/ae93317d/attachment.html>


More information about the llvm-bugs mailing list