summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExceptionSpec.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-14 08:05:40 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-14 08:05:40 +0000
commitdb40c7f57326f6c6f08e0b9e397dd2aff98c4c3a (patch)
treedaa08811e49c7b87259e53d9a1dfd2e0f034ce9b /clang/lib/Sema/SemaExceptionSpec.cpp
parent335f0e4ad4ad19737b378f0f46e95c34e1b8f6a1 (diff)
downloadbcm5719-llvm-db40c7f57326f6c6f08e0b9e397dd2aff98c4c3a.tar.gz
bcm5719-llvm-db40c7f57326f6c6f08e0b9e397dd2aff98c4c3a.zip
Restore r121752 without modification.
llvm-svn: 121763
Diffstat (limited to 'clang/lib/Sema/SemaExceptionSpec.cpp')
-rw-r--r--clang/lib/Sema/SemaExceptionSpec.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 885e52dd76a..d08e84dacd2 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud