From 81c0b5c2006590ee983807b609369e761fa74b5e Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 26 Sep 2011 18:14:24 +0000 Subject: [PATCH] Fix assertion hit when @encoding C++ classes. rdar://10172840 & http://llvm.org/PR10990 llvm-svn: 140542 --- clang/lib/AST/ASTContext.cpp | 5 +++-- clang/test/CodeGenObjCXX/encode.mm | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4d3d88a18d20..fa0ebc8a863d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4583,8 +4583,9 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl, if (base->isEmpty()) continue; uint64_t offs = layout.getVBaseClassOffsetInBits(base); - FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs), - std::make_pair(offs, base)); + if (FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end()) + FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(), + std::make_pair(offs, base)); } } diff --git a/clang/test/CodeGenObjCXX/encode.mm b/clang/test/CodeGenObjCXX/encode.mm index 677f5e2a7c42..8391c04b7da8 100644 --- a/clang/test/CodeGenObjCXX/encode.mm +++ b/clang/test/CodeGenObjCXX/encode.mm @@ -167,3 +167,23 @@ _Alloc_hider _M_dataplus; // CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" const char g5[] = @encode(basic_string); + + +// PR10990 +class CefBase { + virtual ~CefBase() {} +}; +class CefBrowser : public virtual CefBase {}; +class CefBrowserImpl : public CefBrowser {}; +// CHECK: @_ZL2g6 = internal constant [21 x i8] c"{CefBrowserImpl=^^?}\00" +const char g6[] = @encode(CefBrowserImpl); + +// PR10990_2 +class CefBase2 { + virtual ~CefBase2() {} + int i; +}; +class CefBrowser2 : public virtual CefBase2 {}; +class CefBrowserImpl2 : public CefBrowser2 {}; +// CHECK: @_ZL2g7 = internal constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" +const char g7[] = @encode(CefBrowserImpl2);