const Decl *Dcl;
void *Type;
unsigned Loc;
+ unsigned Val;
};
public:
: Kind(Kind), Type(Type.getAsOpaquePtr()) {}
DeclUpdate(unsigned Kind, SourceLocation Loc)
: Kind(Kind), Loc(Loc.getRawEncoding()) {}
+ DeclUpdate(unsigned Kind, unsigned Val)
+ : Kind(Kind), Val(Val) {}
unsigned getKind() const { return Kind; }
const Decl *getDecl() const { return Dcl; }
SourceLocation getLoc() const {
return SourceLocation::getFromRawEncoding(Loc);
}
+ unsigned getNumber() const { return Val; }
};
typedef SmallVector<DeclUpdate, 1> UpdateRecord;
UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER,
UPD_CXX_RESOLVED_EXCEPTION_SPEC,
UPD_CXX_DEDUCED_RETURN_TYPE,
- UPD_DECL_MARKED_USED
+ UPD_DECL_MARKED_USED,
+ UPD_MANGLING_NUMBER,
+ UPD_STATIC_LOCAL_NUMBER
};
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
Record.push_back({UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, NS});
}
+ // Add update records for all mangling numbers and static local numbers.
+ // These aren't really update records, but this is a convenient way of
+ // tagging this rare extra data onto the declarations.
+ for (const auto &Number : Context.MangleNumbers)
+ if (!Number.first->isFromASTFile())
+ DeclUpdates[Number.first].push_back({UPD_MANGLING_NUMBER, Number.second});
+ for (const auto &Number : Context.StaticLocalNumbers)
+ if (!Number.first->isFromASTFile())
+ DeclUpdates[Number.first].push_back({UPD_STATIC_LOCAL_NUMBER,
+ Number.second});
+
// Make sure visible decls, added to DeclContexts previously loaded from
// an AST file, are registered for serialization.
for (SmallVectorImpl<const Decl *>::iterator
} while (!DeclUpdates.empty());
Stream.ExitBlock();
- if (!DeclUpdatesOffsetsRecord.empty())
- Stream.EmitRecord(DECL_UPDATE_OFFSETS, DeclUpdatesOffsetsRecord);
-
DoneWritingDeclsAndTypes = true;
// These things can only be done once we've written out decls and types.
WriteTypeDeclOffsets();
+ if (!DeclUpdatesOffsetsRecord.empty())
+ Stream.EmitRecord(DECL_UPDATE_OFFSETS, DeclUpdatesOffsetsRecord);
WriteCXXBaseSpecifiersOffsets();
WriteFileDeclIDsMap();
WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot);
case UPD_DECL_MARKED_USED:
break;
+
+ case UPD_MANGLING_NUMBER:
+ case UPD_STATIC_LOCAL_NUMBER:
+ Record.push_back(Update.getNumber());
+ break;
}
}
--- /dev/null
+// Test without PCH.
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include %s %s -emit-llvm -o - | FileCheck %s
+//
+// Test with PCH.
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -x c++-header %s -emit-pch -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+struct A {
+ struct { int a; } a;
+ struct { int b; } b;
+};
+
+#else
+
+template<typename T> void f(T) {}
+
+// CHECK-LABEL: define void @_Z1g1A(
+void g(A a) {
+ // CHECK: call void @_Z1fIN1AUt0_EEvT_(
+ f(a.b);
+ // CHECK: call void @_Z1fIN1AUt_EEvT_(
+ f(a.a);
+}
+
+#endif