Skip to content

Commit ed72e29

Browse files
committed
Improve some comments, shrink FunctionType::ExtInfo, and fix a bug found
by valgrind where we were doing the wrong thing in the presence of invalid exception specs. llvm-svn: 121770
1 parent e34793e commit ed72e29

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

clang/include/clang/AST/Type.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,9 +2125,13 @@ class FunctionType : public Type {
21252125
QualType ResultType;
21262126

21272127
public:
2128-
// This class is used for passing around the information needed to
2129-
// construct a call. It is not actually used for storage, just for
2130-
// factoring together common arguments.
2128+
/// ExtInfo - A class which abstracts out some details necessary for
2129+
/// making a call.
2130+
///
2131+
/// It is not actually used directly for storing this information in
2132+
/// a FunctionType, although FunctionType does currently use the
2133+
/// same bit-pattern.
2134+
///
21312135
// If you add a field (say Foo), other than the obvious places (both,
21322136
// constructors, compile failures), what you need to update is
21332137
// * Operator==
@@ -2141,16 +2145,21 @@ class FunctionType : public Type {
21412145
// * TypePrinter::PrintFunctionProto
21422146
// * AST read and write
21432147
// * Codegen
2144-
21452148
class ExtInfo {
2149+
// Feel free to rearrange or add bits, but if you go over 8,
2150+
// you'll need to adjust both the Bits field below and
2151+
// Type::FunctionTypeBitfields.
2152+
2153+
// | CC |noreturn|regparm
2154+
// |0 .. 2| 3 |4 .. 6
21462155
enum { CallConvMask = 0x7 };
21472156
enum { NoReturnMask = 0x8 };
21482157
enum { RegParmMask = ~(CallConvMask | NoReturnMask),
21492158
RegParmOffset = 4 };
21502159

2151-
unsigned Bits;
2160+
unsigned char Bits;
21522161

2153-
ExtInfo(unsigned Bits) : Bits(Bits) {}
2162+
ExtInfo(unsigned Bits) : Bits(static_cast<unsigned char>(Bits)) {}
21542163

21552164
friend class FunctionType;
21562165

clang/lib/Sema/SemaType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,6 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
13271327
if (FTI.hasExceptionSpec) {
13281328
EPI.HasExceptionSpec = FTI.hasExceptionSpec;
13291329
EPI.HasAnyExceptionSpec = FTI.hasAnyExceptionSpec;
1330-
EPI.NumExceptions = FTI.NumExceptions;
13311330
Exceptions.reserve(FTI.NumExceptions);
13321331
for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
13331332
// FIXME: Preserve type source info.
@@ -1337,6 +1336,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
13371336
if (!CheckSpecifiedExceptionType(ET, FTI.Exceptions[ei].Range))
13381337
Exceptions.push_back(ET);
13391338
}
1339+
EPI.NumExceptions = Exceptions.size();
13401340
EPI.Exceptions = Exceptions.data();
13411341
}
13421342

0 commit comments

Comments
 (0)