This test should pass with r186718 now. This test passed for me locally on Windows, probably due to delayed template parsing or something. I built on Linux before committing but did not run the tests due to this longstanding build break: http://llvm.org/bugs/show_bug.cgi?id=13124#c15.
This is a new test, so it's not clear to me that this is a regression. I have a patch that fixes a similar crash, and I need to test if it fixes this crash as well. On Fri, Jul 19, 2013 at 4:30 PM, David Dean <[email protected]> wrote: > Reid, > After this change, the compiler is crashing when running one of > the tests on this bot: > > http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/4672 > > ******************** TEST 'Clang :: > SemaTemplate/instantiate-function-params.cpp' FAILED ******************** > Script: > -- > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/clang > -cc1 -internal-isystem > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/../lib/clang/3.4/include > -fsyntax-only -verify > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/test/SemaTemplate/instantiate-function-params.cpp > -- > Exit Code: 139 > Command Output (stderr): > -- > 0 clang 0x0000000107bcd058 > llvm::sys::PrintStackTrace(__sFILE*) + 40 > 1 clang 0x0000000107bcd5a4 _ZL13SignalHandleri + 644 > 2 libsystem_c.dylib 0x00007fff94461cfa _sigtramp + 26 > 3 libsystem_c.dylib 0x00007fff9442a00e szone_malloc_should_clear + 1115 > 4 clang 0x00000001067de96c > clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*, > llvm::SmallVectorImpl<clang::ParmVarDecl*>&) + 236 > 5 clang 0x00000001067dc0f7 > clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*, > clang::TemplateParameterList*, bool) + 807 > 6 clang 0x00000001067b87f5 > clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, > clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, > clang::TemplateSpecializationKind, bool) + 1189 > 7 clang 0x00000001067ba1a5 > clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, > clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, > bool) + 1749 > 8 clang 0x0000000106809df8 > clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, > clang::QualType, clang::Sema::TypeDiagnoser&) + 968 > 9 clang 0x0000000106809955 > clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, > clang::Sema::TypeDiagnoser&) + 21 > 10 clang 0x00000001067fe385 > clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, > unsigned int) + 37 > 11 clang 0x0000000106514b10 > clang::Sema::CheckParmsForFunctionDef(clang::ParmVarDecl* const*, > clang::ParmVarDecl* const*, bool) + 176 > 12 clang 0x000000010658866c > clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Decl*) + 1580 > 13 clang 0x00000001064af1f3 > clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, > clang::Parser::ParsedTemplateInfo const&, > clang::Parser::LateParsedAttrList*) + 1715 > 14 clang 0x0000000106442c17 > clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool, > clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1319 > 15 clang 0x00000001064ae9c6 > clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, > clang::ParsingDeclSpec&, clang::AccessSpecifier) + 646 > 16 clang 0x00000001064ae417 > clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, > clang::ParsingDeclSpec*, clang::AccessSpecifier) + 359 > 17 clang 0x00000001064ad847 > clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, > clang::ParsingDeclSpec*) + 2615 > 18 clang 0x00000001064534a8 > clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation, > std::allocator<clang::SourceLocation> >&, > std::vector<clang::IdentifierInfo*, std::allocator<clang::IdentifierInfo*> > >&, std::vector<clang::SourceLocation, > std::allocator<clang::SourceLocation> >&, unsigned int, > clang::SourceLocation&, clang::ParsedAttributes&, > clang::BalancedDelimiterTracker&) + 472 > 19 clang 0x0000000106452a7c > clang::Parser::ParseNamespace(unsigned int, clang::SourceLocation&, > clang::SourceLocation) + 4332 > 20 clang 0x000000010643f30c > clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, > unsigned int, clang::SourceLocation&, > clang::Parser::ParsedAttributesWithRange&) + 428 > 21 clang 0x00000001064ad3fd > clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, > clang::ParsingDeclSpec*) + 1517 > 22 clang 0x00000001064acd8e > clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + > 318 > 23 clang 0x00000001064323d6 clang::ParseAST(clang::Sema&, > bool, bool) + 438 > 24 clang 0x000000010618d017 clang::FrontendAction::Execute() + > 119 > 25 clang 0x000000010616658d > clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 973 > 26 clang 0x000000010612d45f > clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3471 > 27 clang 0x000000010612497a cc1_main(char const**, char > const**, char const*, void*) + 826 > 28 clang 0x000000010612b580 main + 9504 > 29 clang 0x0000000106124634 start + 52 > 30 clang 0x0000000000000007 start + 4193106439 > Stack dump: > 0. Program arguments: > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/clang > -cc1 -internal-isystem > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/../lib/clang/3.4/include > -fsyntax-only -verify > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/test/SemaTemplate/instantiate-function-params.cpp > 1. > > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/test/SemaTemplate/instantiate-function-params.cpp:91:20: > current parser token '{' > 2. > > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/test/SemaTemplate/instantiate-function-params.cpp:80:1: > parsing namespace 'InstantiateFunctionTypedef' > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/test/SemaTemplate/Output/instantiate-function-params.cpp.script: > line 1: 14172 Segmentation fault: 11 > > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/clang > -cc1 -internal-isystem > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/../lib/clang/3.4/include > -fsyntax-only -verify > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/test/SemaTemplate/instantiate-function-params.cpp > -- > > ******************** > > > On 19 Jul 2013, at 12:51 PM, Reid Kleckner <[email protected]> wrote: > > > Author: rnk > > Date: Fri Jul 19 14:51:03 2013 > > New Revision: 186714 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=186714&view=rev > > Log: > > Create calling convention AttributedType sugar nodes > > > > Canonical types are unchanged. The type printer had to be changed to > > avoid printing any non-default implicit calling convention as well as > > the calling convention attribute. > > > > Reviewers: rjmccall > > > > Differential Revision: http://llvm-reviews.chandlerc.com/D1132 > > > > Modified: > > cfe/trunk/include/clang/AST/Type.h > > cfe/trunk/lib/AST/Type.cpp > > cfe/trunk/lib/AST/TypePrinter.cpp > > cfe/trunk/lib/Sema/SemaType.cpp > > cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp > > > > Modified: cfe/trunk/include/clang/AST/Type.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=186714&r1=186713&r2=186714&view=diff > > > ============================================================================== > > --- cfe/trunk/include/clang/AST/Type.h (original) > > +++ cfe/trunk/include/clang/AST/Type.h Fri Jul 19 14:51:03 2013 > > @@ -3360,9 +3360,10 @@ public: > > attr_objc_gc, > > attr_objc_ownership, > > attr_pcs, > > + attr_pcs_vfp, > > > > FirstEnumOperandKind = attr_objc_gc, > > - LastEnumOperandKind = attr_pcs, > > + LastEnumOperandKind = attr_pcs_vfp, > > > > // No operand. > > attr_noreturn, > > @@ -3406,16 +3407,9 @@ public: > > bool isSugared() const { return true; } > > QualType desugar() const { return getEquivalentType(); } > > > > - bool isMSTypeSpec() const { > > - switch (getAttrKind()) { > > - default: return false; > > - case attr_ptr32: > > - case attr_ptr64: > > - case attr_sptr: > > - case attr_uptr: > > - return true; > > - } > > - } > > + bool isMSTypeSpec() const; > > + > > + bool isCallingConv() const; > > > > void Profile(llvm::FoldingSetNodeID &ID) { > > Profile(ID, getAttrKind(), ModifiedType, EquivalentType); > > > > Modified: cfe/trunk/lib/AST/Type.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=186714&r1=186713&r2=186714&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/AST/Type.cpp (original) > > +++ cfe/trunk/lib/AST/Type.cpp Fri Jul 19 14:51:03 2013 > > @@ -1842,6 +1842,47 @@ bool TagType::isBeingDefined() const { > > return getDecl()->isBeingDefined(); > > } > > > > +bool AttributedType::isMSTypeSpec() const { > > + switch (getAttrKind()) { > > + default: return false; > > + case attr_ptr32: > > + case attr_ptr64: > > + case attr_sptr: > > + case attr_uptr: > > + return true; > > + } > > + llvm_unreachable("invalid attr kind"); > > +} > > + > > +bool AttributedType::isCallingConv() const { > > + switch (getAttrKind()) { > > + case attr_ptr32: > > + case attr_ptr64: > > + case attr_sptr: > > + case attr_uptr: > > + case attr_address_space: > > + case attr_regparm: > > + case attr_vector_size: > > + case attr_neon_vector_type: > > + case attr_neon_polyvector_type: > > + case attr_objc_gc: > > + case attr_objc_ownership: > > + case attr_noreturn: > > + return false; > > + case attr_pcs: > > + case attr_pcs_vfp: > > + case attr_cdecl: > > + case attr_fastcall: > > + case attr_stdcall: > > + case attr_thiscall: > > + case attr_pascal: > > + case attr_pnaclcall: > > + case attr_inteloclbicc: > > + return true; > > + } > > + llvm_unreachable("invalid attr kind"); > > +} > > + > > CXXRecordDecl *InjectedClassNameType::getDecl() const { > > return cast<CXXRecordDecl>(getInterestingTagDecl(Decl)); > > } > > > > Modified: cfe/trunk/lib/AST/TypePrinter.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=186714&r1=186713&r2=186714&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/AST/TypePrinter.cpp (original) > > +++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Jul 19 14:51:03 2013 > > @@ -81,10 +81,11 @@ namespace { > > class TypePrinter { > > PrintingPolicy Policy; > > bool HasEmptyPlaceHolder; > > + bool InsideCCAttribute; > > > > public: > > explicit TypePrinter(const PrintingPolicy &Policy) > > - : Policy(Policy), HasEmptyPlaceHolder(false) { } > > + : Policy(Policy), HasEmptyPlaceHolder(false), > InsideCCAttribute(false) { } > > > > void print(const Type *ty, Qualifiers qs, raw_ostream &OS, > > StringRef PlaceHolder); > > @@ -630,36 +631,40 @@ void TypePrinter::printFunctionProtoAfte > > OS << ')'; > > > > FunctionType::ExtInfo Info = T->getExtInfo(); > > - switch(Info.getCC()) { > > - case CC_Default: break; > > - case CC_C: > > - OS << " __attribute__((cdecl))"; > > - break; > > - case CC_X86StdCall: > > - OS << " __attribute__((stdcall))"; > > - break; > > - case CC_X86FastCall: > > - OS << " __attribute__((fastcall))"; > > - break; > > - case CC_X86ThisCall: > > - OS << " __attribute__((thiscall))"; > > - break; > > - case CC_X86Pascal: > > - OS << " __attribute__((pascal))"; > > - break; > > - case CC_AAPCS: > > - OS << " __attribute__((pcs(\"aapcs\")))"; > > - break; > > - case CC_AAPCS_VFP: > > - OS << " __attribute__((pcs(\"aapcs-vfp\")))"; > > - break; > > - case CC_PnaclCall: > > - OS << " __attribute__((pnaclcall))"; > > - break; > > - case CC_IntelOclBicc: > > - OS << " __attribute__((intel_ocl_bicc))"; > > - break; > > + > > + if (!InsideCCAttribute) { > > + switch (Info.getCC()) { > > + case CC_Default: break; > > + case CC_C: > > + OS << " __attribute__((cdecl))"; > > + break; > > + case CC_X86StdCall: > > + OS << " __attribute__((stdcall))"; > > + break; > > + case CC_X86FastCall: > > + OS << " __attribute__((fastcall))"; > > + break; > > + case CC_X86ThisCall: > > + OS << " __attribute__((thiscall))"; > > + break; > > + case CC_X86Pascal: > > + OS << " __attribute__((pascal))"; > > + break; > > + case CC_AAPCS: > > + OS << " __attribute__((pcs(\"aapcs\")))"; > > + break; > > + case CC_AAPCS_VFP: > > + OS << " __attribute__((pcs(\"aapcs-vfp\")))"; > > + break; > > + case CC_PnaclCall: > > + OS << " __attribute__((pnaclcall))"; > > + break; > > + case CC_IntelOclBicc: > > + OS << " __attribute__((intel_ocl_bicc))"; > > + break; > > + } > > } > > + > > if (Info.getNoReturn()) > > OS << " __attribute__((noreturn))"; > > if (Info.getRegParm()) > > @@ -1089,7 +1094,7 @@ void TypePrinter::printAttributedBefore( > > case AttributedType::attr_ptr64: OS << " __ptr64"; break; > > case AttributedType::attr_sptr: OS << " __sptr"; break; > > case AttributedType::attr_uptr: OS << " __uptr"; break; > > -} > > + } > > spaceBeforePlaceHolder(OS); > > } > > } > > @@ -1105,6 +1110,12 @@ void TypePrinter::printAttributedAfter(c > > if (T->isMSTypeSpec()) > > return; > > > > + // If this is a calling convention attribute, don't print the > implicit CC from > > + // the modified type. > > + SaveAndRestore<bool> MaybeSuppressCC(InsideCCAttribute, > T->isCallingConv()); > > + > > + printAfter(T->getModifiedType(), OS); > > + > > OS << " __attribute__(("; > > switch (T->getAttrKind()) { > > default: llvm_unreachable("This attribute should have been handled > already"); > > > > Modified: cfe/trunk/lib/Sema/SemaType.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=186714&r1=186713&r2=186714&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/Sema/SemaType.cpp (original) > > +++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jul 19 14:51:03 2013 > > @@ -546,12 +546,7 @@ distributeFunctionTypeAttrToInnermost(Ty > > return true; > > } > > > > - if (handleFunctionTypeAttr(state, attr, declSpecType)) { > > - spliceAttrOutOfList(attr, attrList); > > - return true; > > - } > > - > > - return false; > > + return handleFunctionTypeAttr(state, attr, declSpecType); > > } > > > > /// A function type attribute was written in the decl spec. Try to > > @@ -3345,6 +3340,7 @@ static AttributeList::Kind getAttrListKi > > case AttributedType::attr_pascal: > > return AttributeList::AT_Pascal; > > case AttributedType::attr_pcs: > > + case AttributedType::attr_pcs_vfp: > > return AttributeList::AT_Pcs; > > case AttributedType::attr_pnaclcall: > > return AttributeList::AT_PnaclCall; > > @@ -4302,6 +4298,36 @@ static bool handleMSPointerTypeQualifier > > return false; > > } > > > > +static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr) { > > + assert(!Attr.isInvalid()); > > + switch (Attr.getKind()) { > > + default: > > + llvm_unreachable("not a calling convention attribute"); > > + case AttributeList::AT_CDecl: > > + return AttributedType::attr_cdecl; > > + case AttributeList::AT_FastCall: > > + return AttributedType::attr_fastcall; > > + case AttributeList::AT_StdCall: > > + return AttributedType::attr_stdcall; > > + case AttributeList::AT_ThisCall: > > + return AttributedType::attr_thiscall; > > + case AttributeList::AT_Pascal: > > + return AttributedType::attr_pascal; > > + case AttributeList::AT_Pcs: { > > + // We know attr is valid so it can only have one of two strings > args. > > + StringLiteral *Str = cast<StringLiteral>(Attr.getArg(0)); > > + return llvm::StringSwitch<AttributedType::Kind>(Str->getString()) > > + .Case("aapcs", AttributedType::attr_pcs) > > + .Case("aapcs-vfp", AttributedType::attr_pcs_vfp); > > + } > > + case AttributeList::AT_PnaclCall: > > + return AttributedType::attr_pnaclcall; > > + case AttributeList::AT_IntelOclBicc: > > + return AttributedType::attr_inteloclbicc; > > + } > > + llvm_unreachable("unexpected attribute kind!"); > > +} > > + > > /// Process an individual function attribute. Returns true to > > /// indicate that the attribute was handled, false if it wasn't. > > static bool handleFunctionTypeAttr(TypeProcessingState &state, > > @@ -4421,8 +4447,13 @@ static bool handleFunctionTypeAttr(TypeP > > } > > } > > > > + // Modify the CC from the wrapped function type, wrap it all back, > and then > > + // wrap the whole thing in an AttributedType as written. The > modified type > > + // might have a different CC if we ignored the attribute. > > FunctionType::ExtInfo EI = > unwrapped.get()->getExtInfo().withCallingConv(CC); > > - type = unwrapped.wrap(S, > S.Context.adjustFunctionType(unwrapped.get(), EI)); > > + QualType Equivalent = > > + unwrapped.wrap(S, S.Context.adjustFunctionType(unwrapped.get(), > EI)); > > + type = S.Context.getAttributedType(getCCTypeAttrKind(attr), type, > Equivalent); > > return true; > > } > > > > > > Modified: cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp?rev=186714&r1=186713&r2=186714&view=diff > > > ============================================================================== > > --- cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp > (original) > > +++ cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp Fri Jul > 19 14:51:03 2013 > > @@ -82,9 +82,15 @@ namespace InstantiateFunctionTypedef { > > struct X { > > typedef int functype(int, int); > > functype func; > > + > > + typedef int stdfunctype(int, int) __attribute__((stdcall)); > > + __attribute__((stdcall)) functype stdfunc1; > > + stdfunctype stdfunc2; > > }; > > > > void f(X<int> x) { > > (void)x.func(1, 2); > > + (void)x.stdfunc1(1, 2); > > + (void)x.stdfunc2(1, 2); > > } > > } > > > > > > _______________________________________________ > > cfe-commits mailing list > > [email protected] > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > > -David > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
