Skip to content

Commit deab766

Browse files
committed
noexcept isn't finished just yet:
--- Reverse-merging r127118 into '.': D include/clang/Basic/ExceptionSpecificationType.h U include/clang/Sema/DeclSpec.h U include/clang/AST/Type.h U lib/Sema/SemaDeclCXX.cpp U lib/Sema/SemaExprCXX.cpp U lib/Sema/SemaTemplateInstantiateDecl.cpp U lib/Sema/SemaType.cpp U lib/Sema/SemaExceptionSpec.cpp U lib/Sema/SemaLookup.cpp U lib/AST/Type.cpp U lib/AST/ASTContext.cpp U lib/Serialization/ASTReader.cpp --- Reverse-merging r127111 into '.': G include/clang/Sema/DeclSpec.h U lib/Sema/SemaDecl.cpp U lib/Sema/DeclSpec.cpp G lib/Sema/SemaType.cpp U lib/Parse/ParseDecl.cpp U lib/Parse/ParseExpr.cpp --- Reverse-merging r127086 into '.': A test/Parser/cxx-exception-spec.cpp D test/CXX/except/except.spec/p1.cpp U include/clang/Basic/DiagnosticParseKinds.td G include/clang/Sema/DeclSpec.h U include/clang/Parse/Parser.h G lib/Parse/ParseDecl.cpp U lib/Parse/ParseDeclCXX.cpp llvm-svn: 127611
1 parent 56dba1a commit deab766

21 files changed

+176
-354
lines changed

clang/include/clang/AST/Type.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define LLVM_CLANG_AST_TYPE_H
1616

1717
#include "clang/Basic/Diagnostic.h"
18-
#include "clang/Basic/ExceptionSpecificationType.h"
1918
#include "clang/Basic/IdentifierTable.h"
2019
#include "clang/Basic/Linkage.h"
2120
#include "clang/Basic/PartialDiagnostic.h"
@@ -2404,17 +2403,17 @@ class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode {
24042403
/// ExtProtoInfo - Extra information about a function prototype.
24052404
struct ExtProtoInfo {
24062405
ExtProtoInfo() :
2407-
Variadic(false), ExceptionSpecType(EST_None), TypeQuals(0),
2408-
RefQualifier(RQ_None), NumExceptions(0), Exceptions(0), NoexceptExpr(0) {}
2406+
Variadic(false), HasExceptionSpec(false), HasAnyExceptionSpec(false),
2407+
TypeQuals(0), RefQualifier(RQ_None), NumExceptions(0), Exceptions(0) {}
24092408

24102409
FunctionType::ExtInfo ExtInfo;
24112410
bool Variadic;
2412-
ExceptionSpecificationType ExceptionSpecType;
2411+
bool HasExceptionSpec;
2412+
bool HasAnyExceptionSpec;
24132413
unsigned char TypeQuals;
24142414
RefQualifierKind RefQualifier;
24152415
unsigned NumExceptions;
24162416
const QualType *Exceptions;
2417-
Expr *NoexceptExpr;
24182417
};
24192418

24202419
private:
@@ -2463,8 +2462,8 @@ class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode {
24632462
ExtProtoInfo EPI;
24642463
EPI.ExtInfo = getExtInfo();
24652464
EPI.Variadic = isVariadic();
2466-
EPI.ExceptionSpecType = hasExceptionSpec() ?
2467-
(hasAnyExceptionSpec() ? EST_DynamicAny : EST_Dynamic) : EST_None;
2465+
EPI.HasExceptionSpec = hasExceptionSpec();
2466+
EPI.HasAnyExceptionSpec = hasAnyExceptionSpec();
24682467
EPI.TypeQuals = static_cast<unsigned char>(getTypeQuals());
24692468
EPI.RefQualifier = getRefQualifier();
24702469
EPI.NumExceptions = NumExceptions;

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ def err_expected_lbrace_after_base_specifiers : Error<
300300
"expected '{' after base class list">;
301301
def ext_ellipsis_exception_spec : Extension<
302302
"exception specification of '...' is a Microsoft extension">;
303-
def err_dynamic_and_noexcept_specification : Error<
304-
"cannot have both throw() and noexcept() clause on the same function">;
305303
def err_expected_catch : Error<"expected catch">;
306304
def err_expected_lbrace_or_comma : Error<"expected '{' or ','">;
307305
def err_using_namespace_in_class : Error<

clang/include/clang/Basic/ExceptionSpecificationType.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

clang/include/clang/Parse/Parser.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,18 +1114,11 @@ class Parser : public CodeCompletionHandler {
11141114
//===--------------------------------------------------------------------===//
11151115
// C++ 15: C++ Throw Expression
11161116
ExprResult ParseThrowExpression();
1117-
1118-
ExceptionSpecificationType MaybeParseExceptionSpecification(
1119-
SourceRange &SpecificationRange,
1120-
llvm::SmallVectorImpl<ParsedType> &DynamicExceptions,
1121-
llvm::SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
1122-
ExprResult &NoexceptExpr);
1123-
11241117
// EndLoc is filled with the ___location of the last token of the specification.
1125-
ExceptionSpecificationType ParseDynamicExceptionSpecification(
1126-
SourceRange &SpecificationRange,
1127-
llvm::SmallVectorImpl<ParsedType> &Exceptions,
1128-
llvm::SmallVectorImpl<SourceRange> &Ranges);
1118+
bool ParseExceptionSpecification(SourceLocation &EndLoc,
1119+
llvm::SmallVectorImpl<ParsedType> &Exns,
1120+
llvm::SmallVectorImpl<SourceRange> &Ranges,
1121+
bool &hasAnyExceptionSpec);
11291122

11301123
//===--------------------------------------------------------------------===//
11311124
// C++0x 8: Function declaration trailing-return-type

clang/include/clang/Sema/DeclSpec.h

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "clang/Sema/Ownership.h"
2525
#include "clang/AST/NestedNameSpecifier.h"
2626
#include "clang/Lex/Token.h"
27-
#include "clang/Basic/ExceptionSpecificationType.h"
2827
#include "clang/Basic/OperatorKinds.h"
2928
#include "clang/Basic/Specifiers.h"
3029
#include "llvm/ADT/SmallVector.h"
@@ -1020,8 +1019,11 @@ struct DeclaratorChunk {
10201019
/// The qualifier bitmask values are the same as in QualType.
10211020
unsigned TypeQuals : 3;
10221021

1023-
/// ExceptionSpecType - An ExceptionSpecificationType value.
1024-
unsigned ExceptionSpecType : 3;
1022+
/// hasExceptionSpec - True if the function has an exception specification.
1023+
unsigned hasExceptionSpec : 1;
1024+
1025+
/// hasAnyExceptionSpec - True if the function has a throw(...) specifier.
1026+
unsigned hasAnyExceptionSpec : 1;
10251027

10261028
/// DeleteArgInfo - If this is true, we need to delete[] ArgInfo.
10271029
unsigned DeleteArgInfo : 1;
@@ -1033,34 +1035,28 @@ struct DeclaratorChunk {
10331035
/// declarator.
10341036
unsigned NumArgs;
10351037

1036-
/// NumExceptions - This is the number of types in the dynamic-exception-
1037-
/// decl, if the function has one.
1038+
/// NumExceptions - This is the number of types in the exception-decl, if
1039+
/// the function has one.
10381040
unsigned NumExceptions;
10391041

10401042
/// \brief The ___location of the ref-qualifier, if any.
10411043
///
10421044
/// If this is an invalid ___location, there is no ref-qualifier.
10431045
unsigned RefQualifierLoc;
1044-
1045-
/// \brief When ExceptionSpecType isn't EST_None, the ___location of the
1046+
1047+
/// ThrowLoc - When hasExceptionSpec is true, the ___location of the throw
10461048
/// keyword introducing the spec.
1047-
unsigned ExceptionSpecLoc;
1049+
unsigned ThrowLoc;
10481050

10491051
/// ArgInfo - This is a pointer to a new[]'d array of ParamInfo objects that
10501052
/// describe the arguments for this function declarator. This is null if
10511053
/// there are no arguments specified.
10521054
ParamInfo *ArgInfo;
10531055

1054-
union {
1055-
/// \brief Pointer to a new[]'d array of TypeAndRange objects that
1056-
/// contain the types in the function's dynamic exception specification
1057-
/// and their locations, if there is one.
1058-
TypeAndRange *Exceptions;
1059-
1060-
/// \brief Pointer to the expression in the noexcept-specifier of this
1061-
/// function, if it has one.
1062-
Expr *NoexceptExpr;
1063-
};
1056+
/// Exceptions - This is a pointer to a new[]'d array of TypeAndRange
1057+
/// objects that contain the types in the function's exception
1058+
/// specification and their locations.
1059+
TypeAndRange *Exceptions;
10641060

10651061
/// TrailingReturnType - If this isn't null, it's the trailing return type
10661062
/// specified. This is actually a ParsedType, but stored as void* to
@@ -1080,8 +1076,7 @@ struct DeclaratorChunk {
10801076
void destroy() {
10811077
if (DeleteArgInfo)
10821078
delete[] ArgInfo;
1083-
if (getExceptionSpecType() == EST_Dynamic)
1084-
delete[] Exceptions;
1079+
delete[] Exceptions;
10851080
}
10861081

10871082
/// isKNRPrototype - Return true if this is a K&R style identifier list,
@@ -1094,23 +1089,18 @@ struct DeclaratorChunk {
10941089
SourceLocation getEllipsisLoc() const {
10951090
return SourceLocation::getFromRawEncoding(EllipsisLoc);
10961091
}
1097-
SourceLocation getExceptionSpecLoc() const {
1098-
return SourceLocation::getFromRawEncoding(ExceptionSpecLoc);
1092+
SourceLocation getThrowLoc() const {
1093+
return SourceLocation::getFromRawEncoding(ThrowLoc);
10991094
}
1100-
1095+
11011096
/// \brief Retrieve the ___location of the ref-qualifier, if any.
11021097
SourceLocation getRefQualifierLoc() const {
11031098
return SourceLocation::getFromRawEncoding(RefQualifierLoc);
11041099
}
1105-
1100+
11061101
/// \brief Determine whether this function declaration contains a
11071102
/// ref-qualifier.
11081103
bool hasRefQualifier() const { return getRefQualifierLoc().isValid(); }
1109-
1110-
/// \brief Get the type of exception specification this function has.
1111-
ExceptionSpecificationType getExceptionSpecType() const {
1112-
return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
1113-
}
11141104
};
11151105

11161106
struct BlockPointerTypeInfo : TypeInfoCommon {
@@ -1234,16 +1224,15 @@ struct DeclaratorChunk {
12341224
unsigned TypeQuals,
12351225
bool RefQualifierIsLvalueRef,
12361226
SourceLocation RefQualifierLoc,
1237-
ExceptionSpecificationType ESpecType,
1238-
SourceLocation ESpecLoc,
1227+
bool hasExceptionSpec,
1228+
SourceLocation ThrowLoc,
1229+
bool hasAnyExceptionSpec,
12391230
ParsedType *Exceptions,
12401231
SourceRange *ExceptionRanges,
12411232
unsigned NumExceptions,
1242-
Expr *NoexceptExpr,
12431233
SourceLocation LPLoc, SourceLocation RPLoc,
12441234
Declarator &TheDeclarator,
1245-
ParsedType TrailingReturnType =
1246-
ParsedType());
1235+
ParsedType TrailingReturnType = ParsedType());
12471236

12481237
/// getBlockPointer - Return a DeclaratorChunk for a block.
12491238
///

clang/lib/AST/ASTContext.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@ ASTContext::getFunctionType(QualType ResultTy,
19151915
return QualType(FTP, 0);
19161916

19171917
// Determine whether the type being created is already canonical or not.
1918-
bool isCanonical= EPI.ExceptionSpecType == EST_None && ResultTy.isCanonical();
1918+
bool isCanonical = !EPI.HasExceptionSpec && ResultTy.isCanonical();
19191919
for (unsigned i = 0; i != NumArgs && isCanonical; ++i)
19201920
if (!ArgArray[i].isCanonicalAsParam())
19211921
isCanonical = false;
@@ -1934,8 +1934,11 @@ ASTContext::getFunctionType(QualType ResultTy,
19341934
CanonicalArgs.push_back(getCanonicalParamType(ArgArray[i]));
19351935

19361936
FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
1937-
CanonicalEPI.ExceptionSpecType = EST_None;
1938-
CanonicalEPI.NumExceptions = 0;
1937+
if (CanonicalEPI.HasExceptionSpec) {
1938+
CanonicalEPI.HasExceptionSpec = false;
1939+
CanonicalEPI.HasAnyExceptionSpec = false;
1940+
CanonicalEPI.NumExceptions = 0;
1941+
}
19391942
CanonicalEPI.ExtInfo
19401943
= CanonicalEPI.ExtInfo.withCallingConv(getCanonicalCallConv(CallConv));
19411944

clang/lib/AST/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,8 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args,
11731173
result->containsUnexpandedParameterPack(),
11741174
epi.ExtInfo),
11751175
NumArgs(numArgs), NumExceptions(epi.NumExceptions),
1176-
HasExceptionSpec(isDynamicExceptionSpec(epi.ExceptionSpecType)),
1177-
HasAnyExceptionSpec(epi.ExceptionSpecType == EST_DynamicAny)
1176+
HasExceptionSpec(epi.HasExceptionSpec),
1177+
HasAnyExceptionSpec(epi.HasAnyExceptionSpec)
11781178
{
11791179
// Fill in the trailing argument array.
11801180
QualType *argSlot = reinterpret_cast<QualType*>(this+1);
@@ -1218,8 +1218,8 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
12181218
ID.AddBoolean(epi.Variadic);
12191219
ID.AddInteger(epi.TypeQuals);
12201220
ID.AddInteger(epi.RefQualifier);
1221-
if (isDynamicExceptionSpec(epi.ExceptionSpecType)) {
1222-
ID.AddBoolean(epi.ExceptionSpecType == EST_DynamicAny);
1221+
if (epi.HasExceptionSpec) {
1222+
ID.AddBoolean(epi.HasAnyExceptionSpec);
12231223
for (unsigned i = 0; i != epi.NumExceptions; ++i)
12241224
ID.AddPointer(epi.Exceptions[i].getAsOpaquePtr());
12251225
}

0 commit comments

Comments
 (0)