Skip to content
Snippets Groups Projects
  • Reid Kleckner's avatar
    d4596ba8
    Improve our handling of tag decls in function prototypes · d4596ba8
    Reid Kleckner authored
    r289225 broke AST invariants by reparenting enumerators into function
    decl contexts. This improves things by only reparenting TagDecls while
    also attempting to preserve the lexical declcontext chain. The
    interesting example here is:
      int f(struct S { enum E { a = 1 } b; } c);
    
    The semantic contexts of E and S should be f, and the lexical context of
    S should be f and the lexical context of E should be S. We didn't do
    that with r289225, but now we should.
    
    This change should also improve our behavior on this example:
      void f() {
        extern void ext(struct S { } o);
        // S injected here
      }
    
    Before r289225 we would only remove 'S' from the surrounding tag
    injection context if it was the TU, but now we properly reparent S from
    f to ext.
    
    Fixes PR31366
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289678 91177308-0d34-0410-b5e6-96231b3b80d8
    d4596ba8
    History
    Improve our handling of tag decls in function prototypes
    Reid Kleckner authored
    r289225 broke AST invariants by reparenting enumerators into function
    decl contexts. This improves things by only reparenting TagDecls while
    also attempting to preserve the lexical declcontext chain. The
    interesting example here is:
      int f(struct S { enum E { a = 1 } b; } c);
    
    The semantic contexts of E and S should be f, and the lexical context of
    S should be f and the lexical context of E should be S. We didn't do
    that with r289225, but now we should.
    
    This change should also improve our behavior on this example:
      void f() {
        extern void ext(struct S { } o);
        // S injected here
      }
    
    Before r289225 we would only remove 'S' from the surrounding tag
    injection context if it was the TU, but now we properly reparent S from
    f to ext.
    
    Fixes PR31366
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289678 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.