/// program (e.g., for code generation).
EXTERNAL_DEFINITIONS = 7,
+ /// \brief Record code for the set of non-builtin, special
+ /// types.
+ ///
+ /// This record contains the type IDs for the various type nodes
+ /// that are constructed during semantic analysis (e.g.,
+ /// __builtin_va_list). The SPECIAL_TYPE_* constants provide
+ /// offsets into this record.
+ SPECIAL_TYPES = 8,
+
/// \brief Record code for the block of extra statistics we
/// gather while generating a PCH file.
- STATISTICS = 8
+ STATISTICS = 9
};
/// \brief Record types used within a source manager block.
TYPE_OBJC_QUALIFIED_CLASS = 24
};
+ /// \brief The type IDs for special types constructed by semantic
+ /// analysis.
+ ///
+ /// The constants in this enumeration are indices into the
+ /// SPECIAL_TYPES record.
+ enum SpecialTypeIDs {
+ /// \brief __builtin_va_list
+ SPECIAL_TYPE_BUILTIN_VA_LIST = 0
+ };
+
/// \brief Record codes for each kind of declaration.
///
/// These constants describe the records that can occur within a
/// in the PCH file.
unsigned TotalNumStatements;
+ /// \brief
+ llvm::SmallVector<uint64_t, 4> SpecialTypes;
+
PCHReadResult ReadPCHBlock();
bool CheckPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
ExternalDefinitions.swap(Record);
break;
+ case pch::SPECIAL_TYPES:
+ SpecialTypes.swap(Record);
+ break;
+
case pch::STATISTICS:
TotalNumStatements = Record[0];
break;
// Load the translation unit declaration
ReadDeclRecord(DeclOffsets[0], 0);
+ // Load the special types.
+ Context.setBuiltinVaListType(
+ GetType(SpecialTypes[pch::SPECIAL_TYPE_BUILTIN_VA_LIST]));
+
return Success;
}
DeclsToEmit.push(Context.getTranslationUnitDecl());
// Write the remaining PCH contents.
+ RecordData Record;
Stream.EnterSubblock(pch::PCH_BLOCK_ID, 3);
WriteTargetTriple(Context.Target);
WriteLanguageOptions(Context.getLangOptions());
WriteIdentifierTable();
Stream.EmitRecord(pch::TYPE_OFFSET, TypeOffsets);
Stream.EmitRecord(pch::DECL_OFFSET, DeclOffsets);
+
+ // Write the record of special types.
+ Record.clear();
+ AddTypeRef(Context.getBuiltinVaListType(), Record);
+ Stream.EmitRecord(pch::SPECIAL_TYPES, Record);
+
if (!ExternalDefinitions.empty())
Stream.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions);
// Some simple statistics
- RecordData Record;
+ Record.clear();
Record.push_back(NumStatements);
Stream.EmitRecord(pch::STATISTICS, Record);
Stream.ExitBlock();
// Test this without pch.
-// RUN: clang-cc -triple=x86_64-unknown-freebsd7.0 -include %S/va_arg.h %s
+// RUN: clang-cc -triple=x86_64-unknown-freebsd7.0 -include %S/va_arg.h %s -emit-llvm -o -
// Test with pch.
// RUN: clang-cc -triple=x86_64-unknown-freebsd7.0 -o %t %S/va_arg.h &&
-// RUN: clang-cc -triple=x86_64-unknown-freebsd7.0 -include-pch %t %s
+// RUN: clang-cc -triple=x86_64-unknown-freebsd7.0 -include-pch %t %s -emit-llvm -o -
-// FIXME: Crash when emitting LLVM bitcode using PCH!
char *g0(char** argv, int argc) { return argv[argc]; }
char *g(char **argv) {