https://llvm.org/bugs/show_bug.cgi?id=25209

            Bug ID: 25209
           Summary: Class annotations are not emitted as part of
                    @llvm.global.annotations
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Problem Definition:
    Class annotations are not emitted as part of @llvm.global.annotations
    It is expected that, since CXXRecordDecl is a TopLevel declaration,
    its annotations should appear as part of @llvm.global.annotations

Reproduction:
    // ClassAnnotation.cpp

    // class annotation
    class __attribute__((annotate("ClassAnnotation"))) Foo {
    public:
        int Function();
    };

    int main() {
        Foo* f = new Foo();
        return f->Function();
    }
    // EOF

    clang -cc1 -S -emit-llvm ClassAnnotation.cpp -o - | grep annotation
    <nothing,expecting annotations>

Amateur Analysis:
    Facts:

    1.  The class annotation is recognized as valid syntax and included in
        the AST (See Exhibit A)

    2.  The class annotation is not included in the llvm module emission
        (See Exhibit B)

    3.  All global annotations are associated with a GlobalValue
        (i.e. llvm::Function, llvm::GlobalVariable)
        (See Exhibit C)

    Theory:
    a GlobalValue is created from a ValueDecl (i.e. FunctionDecl, VarDecl)
    CXXRecordDecl is not a ValueDecl, it is a TypeDecl, and thus cannot be
    associated with a global annotation.

    Solution:
    Unknown

Exhibits:

    Exhibit A
        AnnotateAttr is recognized as being a child node of CXXRecordDecl

        clang -cc1 -S -ast-dump ClassAnnotation.cpp
        TranslationUnitDecl 0x4ac2358 <<invalid sloc>> <invalid sloc>
        |-TypedefDecl 0x4ac2648 <<invalid sloc>> <invalid sloc> implicit
        |-CXXRecordDecl 0x4ac2708 <ClassAnnotation.cpp:4:1, line:7:1>
        | |-AnnotateAttr 0x4ac2780 <col:22, col:48> "ClassAnnotation"
        | |-CXXRecordDecl 0x4ac2820 <col:1, col:52> col:52 implicit class Foo
        | |-AccessSpecDecl 0x4ac2880 <line:5:1, col:7> col:1 public
        ...<truncated for bevity>

    Exhibit B
        The AnnotateAttr object was not emitted in the IR

        clang -cc1 -S -emit-llvm ClassAnnotation.cpp -o -| grep annotation
        <nothing,expecting annotations>

    Exhibit C
        This function is called after GV has been created from D via
            EmitGlobalFunctionDefinition
            EmitGlobalVarDefinition

        void CodeGenModule::AddGlobalAnnotations(const ValueDecl *D,
                                             llvm::GlobalValue *GV)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to