Index: clang/lib/AST/Mangle.cpp =================================================================== --- clang/lib/AST/Mangle.cpp +++ clang/lib/AST/Mangle.cpp @@ -225,11 +225,17 @@ if (const CXXMethodDecl *MD = dyn_cast(FD)) if (!MD->isStatic()) ++ArgWords; - for (const auto &AT : Proto->param_types()) + for (const auto &AT : Proto->param_types()) { + // If an argument type is incomplete there is no way to get its size to + // correctly encode into the mangling scheme. + // Follow GCCs behaviour by simply breaking out of the loop. + if (AT->isIncompleteType()) + break; // Size should be aligned to pointer size. ArgWords += llvm::alignTo(ASTContext.getTypeSize(AT), TI.getPointerWidth(0)) / TI.getPointerWidth(0); + } Out << ((TI.getPointerWidth(0) / 8) * ArgWords); } Index: clang/test/CodeGen/pr52782-stdcall-func-decl.cpp =================================================================== --- /dev/null +++ clang/test/CodeGen/pr52782-stdcall-func-decl.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple i686-w64-windows-gnu -o - -emit-llvm -debug-info-kind=constructor %s + +#define NS_IMETHOD_(type) type __stdcall + +enum nsresult {}; + +class NotNull; + +class nsICanvasRenderingContextInternal { + NS_IMETHOD_(nsresult) InitializeWithDrawTarget(NotNull); +} nsTBaseHashSet;