diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp --- a/clang/lib/AST/Mangle.cpp +++ b/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); } diff --git a/clang/test/CodeGen/pr52782-stdcall-func-decl.cpp b/clang/test/CodeGen/pr52782-stdcall-func-decl.cpp new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/pr52782-stdcall-func-decl.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple i686-w64-windows-gnu -o - -emit-llvm -debug-info-kind=constructor %s | FileCheck %s + +enum nsresult {}; + +class NotNull; + +class nsICanvasRenderingContextInternal { + // CHECK: !DISubprogram(name: "InitializeWithDrawTarget", linkageName: "\01__ZN33nsICanvasRenderingContextInternal24InitializeWithDrawTargetE7NotNull@4" + nsresult __stdcall InitializeWithDrawTarget(NotNull); +} nsTBaseHashSet;