diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-04-01 20:22:13 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-04-01 20:22:13 +0000 |
commit | d2f6c726e77c2943f8723d0f9dd65f68b92ef0e0 (patch) | |
tree | daf225448153dbc6d7cb5ebc9aadead62cdb55a7 /clang/lib/Sema/SemaLambda.cpp | |
parent | 084c384c6f644ecf907fd208cd51cf30d67a5940 (diff) | |
download | llvm-d2f6c726e77c2943f8723d0f9dd65f68b92ef0e0.zip llvm-d2f6c726e77c2943f8723d0f9dd65f68b92ef0e0.tar.gz llvm-d2f6c726e77c2943f8723d0f9dd65f68b92ef0e0.tar.bz2 |
Re-land "MS ABI: lambda call operators are instance methods and should use thiscall"
Update the test cases to pass when lambda call operators use thiscall.
Update the lambda-to-block conversion operator to use the default free
function calling convention instead of the call operator's convention.
This reverts commit r233082 and re-instates r233023.
llvm-svn: 233835
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLambda.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 90a81f4..147dd7e 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -1340,22 +1340,27 @@ static void addBlockPointerConversion(Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator) { - const FunctionProtoType *Proto - = CallOperator->getType()->getAs<FunctionProtoType>(); - QualType BlockPtrTy; - { - FunctionProtoType::ExtProtoInfo ExtInfo = Proto->getExtProtoInfo(); - ExtInfo.TypeQuals = 0; - QualType FunctionTy = S.Context.getFunctionType( - Proto->getReturnType(), Proto->getParamTypes(), ExtInfo); - BlockPtrTy = S.Context.getBlockPointerType(FunctionTy); - } + const FunctionProtoType *Proto = + CallOperator->getType()->getAs<FunctionProtoType>(); + + // The function type inside the block pointer type is the same as the call + // operator with some tweaks. The calling convention is the default free + // function convention, and the type qualifications are lost. + FunctionProtoType::ExtProtoInfo BlockEPI = Proto->getExtProtoInfo(); + BlockEPI.ExtInfo = + BlockEPI.ExtInfo.withCallingConv(S.Context.getDefaultCallingConvention( + Proto->isVariadic(), /*IsCXXMethod=*/false)); + BlockEPI.TypeQuals = 0; + QualType FunctionTy = S.Context.getFunctionType( + Proto->getReturnType(), Proto->getParamTypes(), BlockEPI); + QualType BlockPtrTy = S.Context.getBlockPointerType(FunctionTy); + + FunctionProtoType::ExtProtoInfo ConversionEPI( + S.Context.getDefaultCallingConvention( + /*IsVariadic=*/false, /*IsCXXMethod=*/true)); + ConversionEPI.TypeQuals = Qualifiers::Const; + QualType ConvTy = S.Context.getFunctionType(BlockPtrTy, None, ConversionEPI); - FunctionProtoType::ExtProtoInfo ExtInfo(S.Context.getDefaultCallingConvention( - /*IsVariadic=*/false, /*IsCXXMethod=*/true)); - ExtInfo.TypeQuals = Qualifiers::Const; - QualType ConvTy = S.Context.getFunctionType(BlockPtrTy, None, ExtInfo); - SourceLocation Loc = IntroducerRange.getBegin(); DeclarationName Name = S.Context.DeclarationNames.getCXXConversionFunctionName( |