diff options
author | John McCall <rjmccall@apple.com> | 2010-12-14 06:51:39 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-12-14 06:51:39 +0000 |
commit | 0e88aa7100da32acc63bc8a4dcb946ed517868f1 (patch) | |
tree | 1e40b8565309154c96cb5997ad4f615a0b8d6ff4 /lib/Sema/SemaExceptionSpec.cpp | |
parent | 54eeba75d3914e457204a159a7888fc19e50a6dc (diff) |
Factor out most of the extra state in a FunctionProtoType into a separate
class to be passed around. The line between argument and return types and
everything else is kindof vague, but I think it's justifiable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121752 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExceptionSpec.cpp')
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 885e52dd76..d08e84dacd 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -115,6 +115,9 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { if (!MissingExceptionSpecification && !MissingEmptyExceptionSpecification) return true; + const FunctionProtoType *NewProto + = New->getType()->getAs<FunctionProtoType>(); + // The new function declaration is only missing an empty exception // specification "throw()". If the throw() specification came from a // function in a system header that has C linkage, just add an empty @@ -123,42 +126,38 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { // to many libc functions as an optimization. Unfortunately, that // optimization isn't permitted by the C++ standard, so we're forced // to work around it here. - if (MissingEmptyExceptionSpecification && - isa<FunctionProtoType>(New->getType()) && + if (MissingEmptyExceptionSpecification && NewProto && (Old->getLocation().isInvalid() || Context.getSourceManager().isInSystemHeader(Old->getLocation())) && Old->isExternC()) { - const FunctionProtoType *NewProto - = cast<FunctionProtoType>(New->getType()); + FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo(); + EPI.HasExceptionSpec = true; + EPI.HasAnyExceptionSpec = false; + EPI.NumExceptions = 0; QualType NewType = Context.getFunctionType(NewProto->getResultType(), NewProto->arg_type_begin(), NewProto->getNumArgs(), - NewProto->isVariadic(), - NewProto->getTypeQuals(), - true, false, 0, 0, - NewProto->getExtInfo()); + EPI); New->setType(NewType); return false; } - if (MissingExceptionSpecification && isa<FunctionProtoType>(New->getType())) { - const FunctionProtoType *NewProto - = cast<FunctionProtoType>(New->getType()); + if (MissingExceptionSpecification && NewProto) { const FunctionProtoType *OldProto = Old->getType()->getAs<FunctionProtoType>(); + FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo(); + EPI.HasExceptionSpec = OldProto->hasExceptionSpec(); + EPI.HasAnyExceptionSpec = OldProto->hasAnyExceptionSpec(); + EPI.NumExceptions = OldProto->getNumExceptions(); + EPI.Exceptions = OldProto->exception_begin(); + // Update the type of the function with the appropriate exception // specification. QualType NewType = Context.getFunctionType(NewProto->getResultType(), NewProto->arg_type_begin(), NewProto->getNumArgs(), - NewProto->isVariadic(), - NewProto->getTypeQuals(), - OldProto->hasExceptionSpec(), - OldProto->hasAnyExceptionSpec(), - OldProto->getNumExceptions(), - OldProto->exception_begin(), - NewProto->getExtInfo()); + EPI); New->setType(NewType); // If exceptions are disabled, suppress the warning about missing |