From: Douglas Gregor Date: Tue, 22 Dec 2009 18:11:50 +0000 (+0000) Subject: Serialize the NoReturn bit on FunctionTypes for precompiled headers X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9123666ed4ab82182b92f8d978a2801516dcd63d;p=clang Serialize the NoReturn bit on FunctionTypes for precompiled headers git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91911 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 48ef2ac31a..2eabdc93f4 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1854,17 +1854,18 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) { } case pch::TYPE_FUNCTION_NO_PROTO: { - if (Record.size() != 1) { + if (Record.size() != 2) { Error("incorrect encoding of no-proto function type"); return QualType(); } QualType ResultType = GetType(Record[0]); - return Context->getFunctionNoProtoType(ResultType); + return Context->getFunctionNoProtoType(ResultType, Record[1]); } case pch::TYPE_FUNCTION_PROTO: { QualType ResultType = GetType(Record[0]); - unsigned Idx = 1; + bool NoReturn = Record[1]; + unsigned Idx = 2; unsigned NumParams = Record[Idx++]; llvm::SmallVector ParamTypes; for (unsigned I = 0; I != NumParams; ++I) @@ -1880,7 +1881,7 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) { return Context->getFunctionType(ResultType, ParamTypes.data(), NumParams, isVariadic, Quals, hasExceptionSpec, hasAnyExceptionSpec, NumExceptions, - Exceptions.data()); + Exceptions.data(), NoReturn); } case pch::TYPE_UNRESOLVED_USING: diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 0e4516877d..124df63aad 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -144,6 +144,7 @@ void PCHTypeWriter::VisitExtVectorType(const ExtVectorType *T) { void PCHTypeWriter::VisitFunctionType(const FunctionType *T) { Writer.AddTypeRef(T->getResultType(), Record); + Record.push_back(T->getNoReturnAttr()); } void PCHTypeWriter::VisitFunctionNoProtoType(const FunctionNoProtoType *T) { diff --git a/test/PCH/functions.c b/test/PCH/functions.c index fd0c3764b4..eb8579ab2e 100644 --- a/test/PCH/functions.c +++ b/test/PCH/functions.c @@ -18,3 +18,8 @@ void test_g0(int *x, float * y) { g0(y); // expected-warning{{incompatible pointer types passing 'float *', expected 'int *'}} g0(x); } + +void __attribute__((noreturn)) test_abort(int code) { + do_abort(code); +} + diff --git a/test/PCH/functions.h b/test/PCH/functions.h index bc28ad7321..3972430081 100644 --- a/test/PCH/functions.h +++ b/test/PCH/functions.h @@ -4,3 +4,5 @@ int f0(int x, int y, ...); float *f1(float x, float y); void g0(int *); + +void do_abort(int) __attribute__((noreturn));