diff options
Diffstat (limited to 'include/clang/AST/TypeLoc.h')
-rw-r--r-- | include/clang/AST/TypeLoc.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 7de666838d44..5b7d9e6e3ce1 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1351,6 +1351,19 @@ class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, FunctionTypeLoc, FunctionType, FunctionLocInfo> { + bool hasExceptionSpec() const { + if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) { + return FPT->hasExceptionSpec(); + } + return false; + } + + SourceRange *getExceptionSpecRangePtr() const { + assert(hasExceptionSpec() && "No exception spec range"); + // After the Info comes the ParmVarDecl array, and after that comes the + // exception specification information. + return (SourceRange *)(getParmArray() + getNumParams()); + } public: SourceLocation getLocalRangeBegin() const { return getLocalData()->LocalRangeBegin; @@ -1384,6 +1397,16 @@ public: return SourceRange(getLParenLoc(), getRParenLoc()); } + SourceRange getExceptionSpecRange() const { + if (hasExceptionSpec()) + return *getExceptionSpecRangePtr(); + return SourceRange(); + } + void setExceptionSpecRange(SourceRange R) { + if (hasExceptionSpec()) + *getExceptionSpecRangePtr() = R; + } + ArrayRef<ParmVarDecl *> getParams() const { return llvm::makeArrayRef(getParmArray(), getNumParams()); } @@ -1416,12 +1439,15 @@ public: setLocalRangeEnd(Loc); for (unsigned i = 0, e = getNumParams(); i != e; ++i) setParam(i, nullptr); + if (hasExceptionSpec()) + setExceptionSpecRange(Loc); } /// \brief Returns the size of the type source info data block that is /// specific to this type. unsigned getExtraLocalDataSize() const { - return getNumParams() * sizeof(ParmVarDecl *); + unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0; + return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize; } unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); } |