}
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// ValueDecl - Represent the declaration of a variable (in which case it is
/// set that function declaration to the actual declaration
/// containing the body (if there is one).
/// NOTE: For checking if there is a body, use hasBody() instead, to avoid
- /// unnecessary PCH de-serialization of the body.
+ /// unnecessary AST de-serialization of the body.
Stmt *getBody(const FunctionDecl *&Definition) const;
virtual Stmt *getBody() const {
}
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
}
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// EnumDecl - Represents an enum. As an extension, we allow forward-declared
unsigned Access : 2;
friend class CXXClassMemberWrapper;
- /// PCHLevel - the "level" of precompiled header/AST file from which this
- /// declaration was built.
+ /// PCHLevel - the "level" of AST file from which this declaration was built.
unsigned PCHLevel : 2;
/// PCHChanged - if this declaration has changed since being deserialized
}
/// \brief Query whether this declaration was changed in a significant way
- /// since being loaded from a PCH file.
+ /// since being loaded from an AST file.
///
/// In an epic violation of layering, what is "significant" is entirely
- /// up to the PCH system, but implemented in AST and Sema.
+ /// up to the serialization system, but implemented in AST and Sema.
bool isChangedSinceDeserialization() const { return PCHChanged; }
/// \brief Mark this declaration as having changed since deserialization, or
}
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// CXXMethodDecl - Represents a static or instance method of a
static bool classofKind(Kind K) { return K == CXXConstructor; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// CXXDestructorDecl - Represents a C++ destructor within a
static bool classofKind(Kind K) { return K == CXXDestructor; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// CXXConversionDecl - Represents a C++ conversion function within a
static bool classofKind(Kind K) { return K == CXXConversion; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// LinkageSpecDecl - This represents a linkage specification. For example:
static bool classofKind(Kind K) { return K == Using; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// UnresolvedUsingValueDecl - Represents a dependent using
static bool classofKind(Kind K) { return K == Decl::Friend; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// An iterator over the friend declarations of a class.
static bool classofKind(Kind K) { return K == ObjCImplementation; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
}
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
template <class decl_type>
static bool classofKind(Kind K) { return K == FunctionTemplate; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
//===----------------------------------------------------------------------===//
static bool classofKind(Kind K) { return K == TemplateTemplateParm; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// \brief Represents a class template specialization, which refers to
static bool classofKind(Kind K) { return K == ClassTemplate; }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
/// Declaration of a friend template. For example:
virtual child_iterator child_end();
friend class PCHStmtReader;
- friend class PCHStmtWriter;
+ friend class ASTStmtWriter;
};
/// PredefinedExpr - [C99 6.4.2.2] - A predefined identifier such as __func__.
virtual child_iterator child_end();
friend class PCHStmtReader;
- friend class PCHStmtWriter;
+ friend class ASTStmtWriter;
};
virtual child_iterator child_end();
friend class PCHStmtReader;
- friend class PCHStmtWriter;
+ friend class ASTStmtWriter;
};
/// CXXTemporary - Represents a C++ temporary.
redecl_iterator redecls_end() const { return redecl_iterator(); }
friend class PCHDeclReader;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
};
}
//
//===----------------------------------------------------------------------===//
//
-// This file defines the ASTWriter class, which writes a precompiled
-// header containing a serialized representation of a translation
-// unit.
+// This file defines the ASTWriter class, which writes an AST file
+// containing a serialized representation of a translation unit.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_PCH_WRITER_H
public:
typedef llvm::SmallVector<uint64_t, 64> RecordData;
- friend class PCHDeclWriter;
+ friend class ASTDeclWriter;
private:
/// \brief The bitstream writer used to emit this precompiled header.
llvm::BitstreamWriter &Stream;
/// \brief The reader of existing PCH files, if we're chaining.
PCHReader *Chain;
- /// \brief Stores a declaration or a type to be written to the PCH file.
+ /// \brief Stores a declaration or a type to be written to the AST file.
class DeclOrType {
public:
DeclOrType(Decl *D) : Stored(D), IsType(false) { }
/// definitions.
///
/// We keep track of external definitions (as well as tentative
- /// definitions) as we are emitting declarations to the PCH
- /// file. The PCH file contains a separate record for these external
- /// definitions, which are provided to the AST consumer by the PCH
+ /// definitions) as we are emitting declarations to the AST
+ /// file. The AST file contains a separate record for these external
+ /// definitions, which are provided to the AST consumer by the AST
/// reader. This is behavior is required to properly cope with,
/// e.g., tentative variable definitions that occur within
/// headers. The declarations themselves are stored as declaration
/// record.
llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
- /// \brief Namespaces that have received extensions since their PCH form.
+ /// \brief Namespaces that have received extensions since their serialized
+ /// form.
///
/// Basically, when we're chaining and encountering a namespace, we check if
/// its primary namespace comes from the chain. If it does, we add the primary
/// to this set, so that we can write out lexical content updates for it.
llvm::SmallPtrSet<const NamespaceDecl *, 16> UpdatedNamespaces;
- /// \brief Decls that have been replaced in the current dependent PCH.
+ /// \brief Decls that have been replaced in the current dependent AST file.
///
/// When a decl changes fundamentally after being deserialized (this shouldn't
/// happen, but the ObjC AST nodes are designed this way), it will be
/// \brief Mapping from LabelStmt statements to IDs.
std::map<LabelStmt *, unsigned> LabelIDs;
- /// \brief The number of statements written to the PCH file.
+ /// \brief The number of statements written to the AST file.
unsigned NumStatements;
- /// \brief The number of macros written to the PCH file.
+ /// \brief The number of macros written to the AST file.
unsigned NumMacros;
- /// \brief The number of lexical declcontexts written to the PCH
+ /// \brief The number of lexical declcontexts written to the AST
/// file.
unsigned NumLexicalDeclContexts;
- /// \brief The number of visible declcontexts written to the PCH
+ /// \brief The number of visible declcontexts written to the AST
/// file.
unsigned NumVisibleDeclContexts;
//===----------------------------------------------------------------------===//
namespace {
- class PCHTypeWriter {
+ class ASTTypeWriter {
ASTWriter &Writer;
ASTWriter::RecordData &Record;
/// \brief Type code that corresponds to the record generated.
pch::TypeCode Code;
- PCHTypeWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
+ ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
: Writer(Writer), Record(Record), Code(pch::TYPE_EXT_QUAL) { }
void VisitArrayType(const ArrayType *T);
};
}
-void PCHTypeWriter::VisitBuiltinType(const BuiltinType *T) {
+void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
assert(false && "Built-in types are never serialized");
}
-void PCHTypeWriter::VisitComplexType(const ComplexType *T) {
+void ASTTypeWriter::VisitComplexType(const ComplexType *T) {
Writer.AddTypeRef(T->getElementType(), Record);
Code = pch::TYPE_COMPLEX;
}
-void PCHTypeWriter::VisitPointerType(const PointerType *T) {
+void ASTTypeWriter::VisitPointerType(const PointerType *T) {
Writer.AddTypeRef(T->getPointeeType(), Record);
Code = pch::TYPE_POINTER;
}
-void PCHTypeWriter::VisitBlockPointerType(const BlockPointerType *T) {
+void ASTTypeWriter::VisitBlockPointerType(const BlockPointerType *T) {
Writer.AddTypeRef(T->getPointeeType(), Record);
Code = pch::TYPE_BLOCK_POINTER;
}
-void PCHTypeWriter::VisitLValueReferenceType(const LValueReferenceType *T) {
+void ASTTypeWriter::VisitLValueReferenceType(const LValueReferenceType *T) {
Writer.AddTypeRef(T->getPointeeType(), Record);
Code = pch::TYPE_LVALUE_REFERENCE;
}
-void PCHTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
+void ASTTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
Writer.AddTypeRef(T->getPointeeType(), Record);
Code = pch::TYPE_RVALUE_REFERENCE;
}
-void PCHTypeWriter::VisitMemberPointerType(const MemberPointerType *T) {
+void ASTTypeWriter::VisitMemberPointerType(const MemberPointerType *T) {
Writer.AddTypeRef(T->getPointeeType(), Record);
Writer.AddTypeRef(QualType(T->getClass(), 0), Record);
Code = pch::TYPE_MEMBER_POINTER;
}
-void PCHTypeWriter::VisitArrayType(const ArrayType *T) {
+void ASTTypeWriter::VisitArrayType(const ArrayType *T) {
Writer.AddTypeRef(T->getElementType(), Record);
Record.push_back(T->getSizeModifier()); // FIXME: stable values
Record.push_back(T->getIndexTypeCVRQualifiers()); // FIXME: stable values
}
-void PCHTypeWriter::VisitConstantArrayType(const ConstantArrayType *T) {
+void ASTTypeWriter::VisitConstantArrayType(const ConstantArrayType *T) {
VisitArrayType(T);
Writer.AddAPInt(T->getSize(), Record);
Code = pch::TYPE_CONSTANT_ARRAY;
}
-void PCHTypeWriter::VisitIncompleteArrayType(const IncompleteArrayType *T) {
+void ASTTypeWriter::VisitIncompleteArrayType(const IncompleteArrayType *T) {
VisitArrayType(T);
Code = pch::TYPE_INCOMPLETE_ARRAY;
}
-void PCHTypeWriter::VisitVariableArrayType(const VariableArrayType *T) {
+void ASTTypeWriter::VisitVariableArrayType(const VariableArrayType *T) {
VisitArrayType(T);
Writer.AddSourceLocation(T->getLBracketLoc(), Record);
Writer.AddSourceLocation(T->getRBracketLoc(), Record);
Code = pch::TYPE_VARIABLE_ARRAY;
}
-void PCHTypeWriter::VisitVectorType(const VectorType *T) {
+void ASTTypeWriter::VisitVectorType(const VectorType *T) {
Writer.AddTypeRef(T->getElementType(), Record);
Record.push_back(T->getNumElements());
Record.push_back(T->getAltiVecSpecific());
Code = pch::TYPE_VECTOR;
}
-void PCHTypeWriter::VisitExtVectorType(const ExtVectorType *T) {
+void ASTTypeWriter::VisitExtVectorType(const ExtVectorType *T) {
VisitVectorType(T);
Code = pch::TYPE_EXT_VECTOR;
}
-void PCHTypeWriter::VisitFunctionType(const FunctionType *T) {
+void ASTTypeWriter::VisitFunctionType(const FunctionType *T) {
Writer.AddTypeRef(T->getResultType(), Record);
FunctionType::ExtInfo C = T->getExtInfo();
Record.push_back(C.getNoReturn());
Record.push_back(C.getCC());
}
-void PCHTypeWriter::VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
+void ASTTypeWriter::VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
VisitFunctionType(T);
Code = pch::TYPE_FUNCTION_NO_PROTO;
}
-void PCHTypeWriter::VisitFunctionProtoType(const FunctionProtoType *T) {
+void ASTTypeWriter::VisitFunctionProtoType(const FunctionProtoType *T) {
VisitFunctionType(T);
Record.push_back(T->getNumArgs());
for (unsigned I = 0, N = T->getNumArgs(); I != N; ++I)
Code = pch::TYPE_FUNCTION_PROTO;
}
-void PCHTypeWriter::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
+void ASTTypeWriter::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
Code = pch::TYPE_UNRESOLVED_USING;
}
-void PCHTypeWriter::VisitTypedefType(const TypedefType *T) {
+void ASTTypeWriter::VisitTypedefType(const TypedefType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
assert(!T->isCanonicalUnqualified() && "Invalid typedef ?");
Writer.AddTypeRef(T->getCanonicalTypeInternal(), Record);
Code = pch::TYPE_TYPEDEF;
}
-void PCHTypeWriter::VisitTypeOfExprType(const TypeOfExprType *T) {
+void ASTTypeWriter::VisitTypeOfExprType(const TypeOfExprType *T) {
Writer.AddStmt(T->getUnderlyingExpr());
Code = pch::TYPE_TYPEOF_EXPR;
}
-void PCHTypeWriter::VisitTypeOfType(const TypeOfType *T) {
+void ASTTypeWriter::VisitTypeOfType(const TypeOfType *T) {
Writer.AddTypeRef(T->getUnderlyingType(), Record);
Code = pch::TYPE_TYPEOF;
}
-void PCHTypeWriter::VisitDecltypeType(const DecltypeType *T) {
+void ASTTypeWriter::VisitDecltypeType(const DecltypeType *T) {
Writer.AddStmt(T->getUnderlyingExpr());
Code = pch::TYPE_DECLTYPE;
}
-void PCHTypeWriter::VisitTagType(const TagType *T) {
+void ASTTypeWriter::VisitTagType(const TagType *T) {
Record.push_back(T->isDependentType());
Writer.AddDeclRef(T->getDecl(), Record);
assert(!T->isBeingDefined() &&
"Cannot serialize in the middle of a type definition");
}
-void PCHTypeWriter::VisitRecordType(const RecordType *T) {
+void ASTTypeWriter::VisitRecordType(const RecordType *T) {
VisitTagType(T);
Code = pch::TYPE_RECORD;
}
-void PCHTypeWriter::VisitEnumType(const EnumType *T) {
+void ASTTypeWriter::VisitEnumType(const EnumType *T) {
VisitTagType(T);
Code = pch::TYPE_ENUM;
}
void
-PCHTypeWriter::VisitSubstTemplateTypeParmType(
+ASTTypeWriter::VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
Writer.AddTypeRef(QualType(T->getReplacedParameter(), 0), Record);
Writer.AddTypeRef(T->getReplacementType(), Record);
}
void
-PCHTypeWriter::VisitTemplateSpecializationType(
+ASTTypeWriter::VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
Record.push_back(T->isDependentType());
Writer.AddTemplateName(T->getTemplateName(), Record);
}
void
-PCHTypeWriter::VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
+ASTTypeWriter::VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
VisitArrayType(T);
Writer.AddStmt(T->getSizeExpr());
Writer.AddSourceRange(T->getBracketsRange(), Record);
}
void
-PCHTypeWriter::VisitDependentSizedExtVectorType(
+ASTTypeWriter::VisitDependentSizedExtVectorType(
const DependentSizedExtVectorType *T) {
// FIXME: Serialize this type (C++ only)
assert(false && "Cannot serialize dependent sized extended vector types");
}
void
-PCHTypeWriter::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
+ASTTypeWriter::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
Record.push_back(T->getDepth());
Record.push_back(T->getIndex());
Record.push_back(T->isParameterPack());
}
void
-PCHTypeWriter::VisitDependentNameType(const DependentNameType *T) {
+ASTTypeWriter::VisitDependentNameType(const DependentNameType *T) {
Record.push_back(T->getKeyword());
Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
Writer.AddIdentifierRef(T->getIdentifier(), Record);
}
void
-PCHTypeWriter::VisitDependentTemplateSpecializationType(
+ASTTypeWriter::VisitDependentTemplateSpecializationType(
const DependentTemplateSpecializationType *T) {
Record.push_back(T->getKeyword());
Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
Code = pch::TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION;
}
-void PCHTypeWriter::VisitElaboratedType(const ElaboratedType *T) {
+void ASTTypeWriter::VisitElaboratedType(const ElaboratedType *T) {
Record.push_back(T->getKeyword());
Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
Writer.AddTypeRef(T->getNamedType(), Record);
Code = pch::TYPE_ELABORATED;
}
-void PCHTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) {
+void ASTTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
Writer.AddTypeRef(T->getInjectedSpecializationType(), Record);
Code = pch::TYPE_INJECTED_CLASS_NAME;
}
-void PCHTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
+void ASTTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
Code = pch::TYPE_OBJC_INTERFACE;
}
-void PCHTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
+void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
Writer.AddTypeRef(T->getBaseType(), Record);
Record.push_back(T->getNumProtocols());
for (ObjCObjectType::qual_iterator I = T->qual_begin(),
}
void
-PCHTypeWriter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
+ASTTypeWriter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
Writer.AddTypeRef(T->getPointeeType(), Record);
Code = pch::TYPE_OBJC_OBJECT_POINTER;
}
#define BLOCK(X) EmitBlockID(pch::X ## _ID, #X, Stream, Record)
#define RECORD(X) EmitRecordID(pch::X, #X, Stream, Record)
- // PCH Top-Level Block.
+ // AST Top-Level Block.
BLOCK(PCH_BLOCK);
RECORD(ORIGINAL_FILE_NAME);
RECORD(TYPE_OFFSET);
return Filename + Pos;
}
-/// \brief Write the PCH metadata (e.g., i686-apple-darwin9).
+/// \brief Write the AST metadata (e.g., i686-apple-darwin9).
void ASTWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
using namespace llvm;
BitCodeAbbrev *MetaAbbrev = new BitCodeAbbrev();
MetaAbbrev->Add(BitCodeAbbrevOp(
Chain ? pch::CHAINED_METADATA : pch::METADATA));
- MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // PCH major
- MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // PCH minor
+ MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // AST major
+ MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // AST minor
MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang major
MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang minor
MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
namespace {
// Trait used for the on-disk hash table of stat cache results.
-class PCHStatCacheTrait {
+class ASTStatCacheTrait {
public:
typedef const char * key_type;
typedef key_type key_type_ref;
};
} // end anonymous namespace
-/// \brief Write the stat() system call cache to the PCH file.
+/// \brief Write the stat() system call cache to the AST file.
void ASTWriter::WriteStatCache(MemorizeStatCalls &StatCalls) {
// Build the on-disk hash table containing information about every
// stat() call.
- OnDiskChainedHashTableGenerator<PCHStatCacheTrait> Generator;
+ OnDiskChainedHashTableGenerator<ASTStatCacheTrait> Generator;
unsigned NumStatEntries = 0;
for (MemorizeStatCalls::iterator Stat = StatCalls.begin(),
StatEnd = StatCalls.end();
if (SLocEntryOffsets.empty())
return;
- // Write the source-location offsets table into the PCH block. This
+ // Write the source-location offsets table into the AST block. This
// table is used for lazily loading source-location information.
using namespace llvm;
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
(const char *)data(SLocEntryOffsets),
SLocEntryOffsets.size()*sizeof(SLocEntryOffsets[0]));
- // Write the source location entry preloads array, telling the PCH
+ // Write the source location entry preloads array, telling the AST
// reader which source locations entries it should load eagerly.
Stream.EmitRecord(pch::SOURCE_LOCATION_PRELOADS, PreloadSLocs);
}
// Enter the preprocessor block.
Stream.EnterSubblock(pch::PREPROCESSOR_BLOCK_ID, 2);
- // If the PCH file contains __DATE__ or __TIME__ emit a warning about this.
+ // If the AST file contains __DATE__ or __TIME__ emit a warning about this.
// FIXME: use diagnostics subsystem for localization etc.
if (PP.SawDateOrTime())
fprintf(stderr, "warning: precompiled header used __DATE__ or __TIME__.\n");
// order so that output is reproducible.
MacroInfo *MI = I->second;
- // Don't emit builtin macros like __LINE__ to the PCH file unless they have
+ // Don't emit builtin macros like __LINE__ to the AST file unless they have
// been redefined by the header (in which case they are not isBuiltinMacro).
- // Also skip macros from a PCH file if we're chaining.
+ // Also skip macros from a AST file if we're chaining.
if (MI->isBuiltinMacro() || (Chain && MI->isFromPCH()))
continue;
// Type Serialization
//===----------------------------------------------------------------------===//
-/// \brief Write the representation of a type to the PCH stream.
+/// \brief Write the representation of a type to the AST stream.
void ASTWriter::WriteType(QualType T) {
pch::TypeID &ID = TypeIDs[T];
if (ID == 0) // we haven't seen this type before.
RecordData Record;
// Emit the type's representation.
- PCHTypeWriter W(*this, Record);
+ ASTTypeWriter W(*this, Record);
if (T.hasLocalNonFastQualifiers()) {
Qualifiers Qs = T.getLocalQualifiers();
namespace {
// Trait used for the on-disk hash table used in the method pool.
-class PCHMethodPoolTrait {
+class ASTMethodPoolTrait {
ASTWriter &Writer;
public:
};
typedef const data_type& data_type_ref;
- explicit PCHMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) { }
+ explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) { }
static unsigned ComputeHash(Selector Sel) {
unsigned N = Sel.getNumArgs();
unsigned NumTableEntries = 0;
// Create and write out the blob that contains selectors and the method pool.
{
- OnDiskChainedHashTableGenerator<PCHMethodPoolTrait> Generator;
+ OnDiskChainedHashTableGenerator<ASTMethodPoolTrait> Generator;
// Create the on-disk hash table representation. We walk through every
// selector we've seen and look it up in the method pool.
I != E; ++I) {
Selector S = I->first;
Sema::GlobalMethodPool::iterator F = SemaRef.MethodPool.find(S);
- PCHMethodPoolTrait::data_type Data = {
+ ASTMethodPoolTrait::data_type Data = {
I->second,
ObjCMethodList(),
ObjCMethodList()
Data.Instance = F->second.first;
Data.Factory = F->second.second;
}
- // Only write this selector if it's not in an existing PCH or something
+ // Only write this selector if it's not in an existing AST or something
// changed.
if (Chain && I->second < FirstSelectorID) {
// Selector already exists. Did it change?
llvm::SmallString<4096> MethodPool;
uint32_t BucketOffset;
{
- PCHMethodPoolTrait Trait(*this);
+ ASTMethodPoolTrait Trait(*this);
llvm::raw_svector_ostream Out(MethodPool);
// Make sure that no bucket is at offset 0
clang::io::Emit32(Out, 0);
}
}
-/// \brief Write the selectors referenced in @selector expression into PCH file.
+/// \brief Write the selectors referenced in @selector expression into AST file.
void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
using namespace llvm;
if (SemaRef.ReferencedSelectors.empty())
RecordData Record;
- // Note: this writes out all references even for a dependent PCH. But it is
+ // Note: this writes out all references even for a dependent AST. But it is
// very tricky to fix, and given that @selector shouldn't really appear in
// headers, probably not worth it. It's not a correctness issue.
for (DenseMap<Selector, SourceLocation>::iterator S =
//===----------------------------------------------------------------------===//
namespace {
-class PCHIdentifierTableTrait {
+class ASTIdentifierTableTrait {
ASTWriter &Writer;
Preprocessor &PP;
typedef pch::IdentID data_type;
typedef data_type data_type_ref;
- PCHIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP)
+ ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP)
: Writer(Writer), PP(PP) { }
static unsigned ComputeHash(const IdentifierInfo* II) {
};
} // end anonymous namespace
-/// \brief Write the identifier table into the PCH file.
+/// \brief Write the identifier table into the AST file.
///
/// The identifier table consists of a blob containing string data
/// (the actual identifiers themselves) and a separate "offsets" index
// Create and write out the blob that contains the identifier
// strings.
{
- OnDiskChainedHashTableGenerator<PCHIdentifierTableTrait> Generator;
+ OnDiskChainedHashTableGenerator<ASTIdentifierTableTrait> Generator;
// Look for any identifiers that were named while processing the
// headers, but are otherwise not needed. We add these to the hash
// table to enable checking of the predefines buffer in the case
- // where the user adds new macro definitions when building the PCH
+ // where the user adds new macro definitions when building the AST
// file.
for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),
IDEnd = PP.getIdentifierTable().end();
llvm::SmallString<4096> IdentifierTable;
uint32_t BucketOffset;
{
- PCHIdentifierTableTrait Trait(*this, PP);
+ ASTIdentifierTableTrait Trait(*this, PP);
llvm::raw_svector_ostream Out(IdentifierTable);
// Make sure that no bucket is at offset 0
clang::io::Emit32(Out, 0);
/// within the identifier table.
void ASTWriter::SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset) {
pch::IdentID ID = IdentifierIDs[II];
- // Only store offsets new to this PCH file. Other identifier names are looked
+ // Only store offsets new to this AST file. Other identifier names are looked
// up earlier in the chain and thus don't need an offset.
if (ID >= FirstIdentID)
IdentifierOffsets[ID - FirstIdentID] = Offset;
// declarations in this header file. Generally, this record will be
// empty.
RecordData LocallyScopedExternalDecls;
- // FIXME: This is filling in the PCH file in densemap order which is
+ // FIXME: This is filling in the AST file in densemap order which is
// nondeterminstic!
for (llvm::DenseMap<DeclarationName, NamedDecl *>::iterator
TD = SemaRef.LocallyScopedExternalDecls.begin(),
AddDeclRef(SemaRef.getStdBadAlloc(), SemaDeclRefs);
}
- // Write the remaining PCH contents.
+ // Write the remaining AST contents.
RecordData Record;
Stream.EnterSubblock(pch::PCH_BLOCK_ID, 5);
WriteMetadata(Context, isysroot);
// declarations in this header file. Generally, this record will be
// empty.
RecordData LocallyScopedExternalDecls;
- // FIXME: This is filling in the PCH file in densemap order which is
+ // FIXME: This is filling in the AST file in densemap order which is
// nondeterminstic!
for (llvm::DenseMap<DeclarationName, NamedDecl *>::iterator
TD = SemaRef.LocallyScopedExternalDecls.begin(),
WriteTypeDeclOffsets();
/// Build a record containing first declarations from a chained PCH and the
- /// most recent declarations in this PCH that they point to.
+ /// most recent declarations in this AST that they point to.
RecordData FirstLatestDeclIDs;
for (FirstLatestDeclMap::iterator
I = FirstLatestDecls.begin(), E = FirstLatestDecls.end(); I != E; ++I) {
//===----------------------------------------------------------------------===//
namespace clang {
- class PCHDeclWriter : public DeclVisitor<PCHDeclWriter, void> {
+ class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
ASTWriter &Writer;
ASTContext &Context;
pch::DeclCode Code;
unsigned AbbrevToUse;
- PCHDeclWriter(ASTWriter &Writer, ASTContext &Context,
+ ASTDeclWriter(ASTWriter &Writer, ASTContext &Context,
ASTWriter::RecordData &Record)
: Writer(Writer), Context(Context), Record(Record) {
}
};
}
-void PCHDeclWriter::Visit(Decl *D) {
- DeclVisitor<PCHDeclWriter>::Visit(D);
+void ASTDeclWriter::Visit(Decl *D) {
+ DeclVisitor<ASTDeclWriter>::Visit(D);
// Handle FunctionDecl's body here and write it after all other Stmts/Exprs
// have been written. We want it last because we will not read it back when
- // retrieving it from the PCH, we'll just lazily set the offset.
+ // retrieving it from the AST, we'll just lazily set the offset.
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
Record.push_back(FD->isThisDeclarationADefinition());
if (FD->isThisDeclarationADefinition())
}
}
-void PCHDeclWriter::VisitDecl(Decl *D) {
+void ASTDeclWriter::VisitDecl(Decl *D) {
Writer.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()), Record);
Writer.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()), Record);
Writer.AddSourceLocation(D->getLocation(), Record);
Record.push_back(D->getPCHLevel());
}
-void PCHDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
+void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
VisitDecl(D);
Writer.AddDeclRef(D->getAnonymousNamespace(), Record);
Code = pch::DECL_TRANSLATION_UNIT;
}
-void PCHDeclWriter::VisitNamedDecl(NamedDecl *D) {
+void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) {
VisitDecl(D);
Writer.AddDeclarationName(D->getDeclName(), Record);
}
-void PCHDeclWriter::VisitTypeDecl(TypeDecl *D) {
+void ASTDeclWriter::VisitTypeDecl(TypeDecl *D) {
VisitNamedDecl(D);
Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
}
-void PCHDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
+void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
VisitTypeDecl(D);
Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
Code = pch::DECL_TYPEDEF;
}
-void PCHDeclWriter::VisitTagDecl(TagDecl *D) {
+void ASTDeclWriter::VisitTagDecl(TagDecl *D) {
VisitTypeDecl(D);
Record.push_back(D->getIdentifierNamespace());
VisitRedeclarable(D);
Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record);
}
-void PCHDeclWriter::VisitEnumDecl(EnumDecl *D) {
+void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
VisitTagDecl(D);
Writer.AddTypeRef(D->getIntegerType(), Record);
Writer.AddTypeRef(D->getPromotionType(), Record);
Code = pch::DECL_ENUM;
}
-void PCHDeclWriter::VisitRecordDecl(RecordDecl *D) {
+void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
VisitTagDecl(D);
Record.push_back(D->hasFlexibleArrayMember());
Record.push_back(D->isAnonymousStructOrUnion());
Code = pch::DECL_RECORD;
}
-void PCHDeclWriter::VisitValueDecl(ValueDecl *D) {
+void ASTDeclWriter::VisitValueDecl(ValueDecl *D) {
VisitNamedDecl(D);
Writer.AddTypeRef(D->getType(), Record);
}
-void PCHDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) {
+void ASTDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) {
VisitValueDecl(D);
Record.push_back(D->getInitExpr()? 1 : 0);
if (D->getInitExpr())
Code = pch::DECL_ENUM_CONSTANT;
}
-void PCHDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
+void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
VisitValueDecl(D);
Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
// FIXME: write optional qualifier and its range.
}
-void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
+void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
VisitDeclaratorDecl(D);
// FIXME: write DeclarationNameLoc.
}
}
- // FunctionDecl's body is handled last at PCHWriterDecl::Visit,
+ // FunctionDecl's body is handled last at ASTWriterDecl::Visit,
// after everything else is written.
VisitRedeclarable(D);
Code = pch::DECL_FUNCTION;
}
-void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
+void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
VisitNamedDecl(D);
// FIXME: convert to LazyStmtPtr?
// Unlike C/C++, method bodies will never be in header files.
Code = pch::DECL_OBJC_METHOD;
}
-void PCHDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) {
+void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) {
VisitNamedDecl(D);
Writer.AddSourceRange(D->getAtEndRange(), Record);
// Abstract class (no need to define a stable pch::DECL code).
}
-void PCHDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
+void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
VisitObjCContainerDecl(D);
Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
Writer.AddDeclRef(D->getSuperClass(), Record);
Code = pch::DECL_OBJC_INTERFACE;
}
-void PCHDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) {
+void ASTDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) {
VisitFieldDecl(D);
// FIXME: stable encoding for @public/@private/@protected/@package
Record.push_back(D->getAccessControl());
Code = pch::DECL_OBJC_IVAR;
}
-void PCHDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
+void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
VisitObjCContainerDecl(D);
Record.push_back(D->isForwardDecl());
Writer.AddSourceLocation(D->getLocEnd(), Record);
Code = pch::DECL_OBJC_PROTOCOL;
}
-void PCHDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) {
+void ASTDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) {
VisitFieldDecl(D);
Code = pch::DECL_OBJC_AT_DEFS_FIELD;
}
-void PCHDeclWriter::VisitObjCClassDecl(ObjCClassDecl *D) {
+void ASTDeclWriter::VisitObjCClassDecl(ObjCClassDecl *D) {
VisitDecl(D);
Record.push_back(D->size());
for (ObjCClassDecl::iterator I = D->begin(), IEnd = D->end(); I != IEnd; ++I)
Code = pch::DECL_OBJC_CLASS;
}
-void PCHDeclWriter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
+void ASTDeclWriter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
VisitDecl(D);
Record.push_back(D->protocol_size());
for (ObjCForwardProtocolDecl::protocol_iterator
Code = pch::DECL_OBJC_FORWARD_PROTOCOL;
}
-void PCHDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
+void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
VisitObjCContainerDecl(D);
Writer.AddDeclRef(D->getClassInterface(), Record);
Record.push_back(D->protocol_size());
Code = pch::DECL_OBJC_CATEGORY;
}
-void PCHDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) {
+void ASTDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) {
VisitNamedDecl(D);
Writer.AddDeclRef(D->getClassInterface(), Record);
Code = pch::DECL_OBJC_COMPATIBLE_ALIAS;
}
-void PCHDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
+void ASTDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
VisitNamedDecl(D);
Writer.AddSourceLocation(D->getAtLoc(), Record);
Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
Code = pch::DECL_OBJC_PROPERTY;
}
-void PCHDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) {
+void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) {
VisitObjCContainerDecl(D);
Writer.AddDeclRef(D->getClassInterface(), Record);
// Abstract class (no need to define a stable pch::DECL code).
}
-void PCHDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
+void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
VisitObjCImplDecl(D);
Writer.AddIdentifierRef(D->getIdentifier(), Record);
Code = pch::DECL_OBJC_CATEGORY_IMPL;
}
-void PCHDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
+void ASTDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
Writer.AddDeclRef(D->getSuperClass(), Record);
Writer.AddCXXBaseOrMemberInitializers(D->IvarInitializers,
Code = pch::DECL_OBJC_IMPLEMENTATION;
}
-void PCHDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
+void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
VisitDecl(D);
Writer.AddSourceLocation(D->getLocStart(), Record);
Writer.AddDeclRef(D->getPropertyDecl(), Record);
Code = pch::DECL_OBJC_PROPERTY_IMPL;
}
-void PCHDeclWriter::VisitFieldDecl(FieldDecl *D) {
+void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
VisitDeclaratorDecl(D);
Record.push_back(D->isMutable());
Record.push_back(D->getBitWidth()? 1 : 0);
Code = pch::DECL_FIELD;
}
-void PCHDeclWriter::VisitVarDecl(VarDecl *D) {
+void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
VisitDeclaratorDecl(D);
Record.push_back(D->getStorageClass()); // FIXME: stable encoding
Record.push_back(D->getStorageClassAsWritten());
Code = pch::DECL_VAR;
}
-void PCHDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
+void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
VisitVarDecl(D);
Code = pch::DECL_IMPLICIT_PARAM;
}
-void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
+void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
VisitVarDecl(D);
Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
Record.push_back(D->hasInheritedDefaultArg());
"PARM_VAR_DECL can't be static data member");
}
-void PCHDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
+void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
VisitDecl(D);
Writer.AddStmt(D->getAsmString());
Code = pch::DECL_FILE_SCOPE_ASM;
}
-void PCHDeclWriter::VisitBlockDecl(BlockDecl *D) {
+void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) {
VisitDecl(D);
Writer.AddStmt(D->getBody());
Writer.AddTypeSourceInfo(D->getSignatureAsWritten(), Record);
Code = pch::DECL_BLOCK;
}
-void PCHDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
+void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
VisitDecl(D);
// FIXME: It might be nice to serialize the brace locations for this
// declaration, which don't seem to be readily available in the AST.
Code = pch::DECL_LINKAGE_SPEC;
}
-void PCHDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) {
+void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) {
VisitNamedDecl(D);
Writer.AddSourceLocation(D->getLBracLoc(), Record);
Writer.AddSourceLocation(D->getRBracLoc(), Record);
}
}
-void PCHDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
+void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
VisitNamedDecl(D);
Writer.AddSourceLocation(D->getAliasLoc(), Record);
Writer.AddSourceRange(D->getQualifierRange(), Record);
Code = pch::DECL_NAMESPACE_ALIAS;
}
-void PCHDeclWriter::VisitUsingDecl(UsingDecl *D) {
+void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) {
VisitNamedDecl(D);
Writer.AddSourceRange(D->getNestedNameRange(), Record);
Writer.AddSourceLocation(D->getUsingLocation(), Record);
Code = pch::DECL_USING;
}
-void PCHDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {
+void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {
VisitNamedDecl(D);
Writer.AddDeclRef(D->getTargetDecl(), Record);
Writer.AddDeclRef(D->getUsingDecl(), Record);
Code = pch::DECL_USING_SHADOW;
}
-void PCHDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
+void ASTDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
VisitNamedDecl(D);
Writer.AddSourceLocation(D->getNamespaceKeyLocation(), Record);
Writer.AddSourceRange(D->getQualifierRange(), Record);
Code = pch::DECL_USING_DIRECTIVE;
}
-void PCHDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
+void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
VisitValueDecl(D);
Writer.AddSourceRange(D->getTargetNestedNameRange(), Record);
Writer.AddSourceLocation(D->getUsingLoc(), Record);
Code = pch::DECL_UNRESOLVED_USING_VALUE;
}
-void PCHDeclWriter::VisitUnresolvedUsingTypenameDecl(
+void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl(
UnresolvedUsingTypenameDecl *D) {
VisitTypeDecl(D);
Writer.AddSourceRange(D->getTargetNestedNameRange(), Record);
Code = pch::DECL_UNRESOLVED_USING_TYPENAME;
}
-void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
+void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
// See comments at PCHDeclReader::VisitCXXRecordDecl about why this happens
// before VisitRecordDecl.
enum { Data_NoDefData, Data_Owner, Data_NotOwner };
Code = pch::DECL_CXX_RECORD;
}
-void PCHDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
+void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
VisitFunctionDecl(D);
Record.push_back(D->size_overridden_methods());
for (CXXMethodDecl::method_iterator
Code = pch::DECL_CXX_METHOD;
}
-void PCHDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
+void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
VisitCXXMethodDecl(D);
Record.push_back(D->IsExplicitSpecified);
Code = pch::DECL_CXX_CONSTRUCTOR;
}
-void PCHDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
+void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
VisitCXXMethodDecl(D);
Record.push_back(D->ImplicitlyDefined);
Code = pch::DECL_CXX_DESTRUCTOR;
}
-void PCHDeclWriter::VisitCXXConversionDecl(CXXConversionDecl *D) {
+void ASTDeclWriter::VisitCXXConversionDecl(CXXConversionDecl *D) {
VisitCXXMethodDecl(D);
Record.push_back(D->IsExplicitSpecified);
Code = pch::DECL_CXX_CONVERSION;
}
-void PCHDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) {
+void ASTDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) {
VisitDecl(D);
Writer.AddSourceLocation(D->getColonLoc(), Record);
Code = pch::DECL_ACCESS_SPEC;
}
-void PCHDeclWriter::VisitFriendDecl(FriendDecl *D) {
+void ASTDeclWriter::VisitFriendDecl(FriendDecl *D) {
VisitDecl(D);
Record.push_back(D->Friend.is<TypeSourceInfo*>());
if (D->Friend.is<TypeSourceInfo*>())
Code = pch::DECL_FRIEND;
}
-void PCHDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
+void ASTDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
VisitDecl(D);
Record.push_back(D->getNumTemplateParameters());
for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
Code = pch::DECL_FRIEND_TEMPLATE;
}
-void PCHDeclWriter::VisitTemplateDecl(TemplateDecl *D) {
+void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) {
VisitNamedDecl(D);
Writer.AddDeclRef(D->getTemplatedDecl(), Record);
Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
}
-void PCHDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
+void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
VisitTemplateDecl(D);
Record.push_back(D->getIdentifierNamespace());
assert(First != D);
// If this is a most recent redeclaration that is pointed to by a first decl
// in a chained PCH, keep track of the association with the map so we can
- // update the first decl during PCH reading.
+ // update the first decl during AST reading.
if (First->getMostRecentDeclaration() == D &&
First->getPCHLevel() > D->getPCHLevel()) {
assert(Writer.FirstLatestDecls.find(First)==Writer.FirstLatestDecls.end()
}
}
-void PCHDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
+void ASTDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
VisitRedeclarableTemplateDecl(D);
if (D->getPreviousDeclaration() == 0) {
Code = pch::DECL_CLASS_TEMPLATE;
}
-void PCHDeclWriter::VisitClassTemplateSpecializationDecl(
+void ASTDeclWriter::VisitClassTemplateSpecializationDecl(
ClassTemplateSpecializationDecl *D) {
VisitCXXRecordDecl(D);
Code = pch::DECL_CLASS_TEMPLATE_SPECIALIZATION;
}
-void PCHDeclWriter::VisitClassTemplatePartialSpecializationDecl(
+void ASTDeclWriter::VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D) {
VisitClassTemplateSpecializationDecl(D);
Code = pch::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION;
}
-void PCHDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
+void ASTDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
VisitRedeclarableTemplateDecl(D);
if (D->getPreviousDeclaration() == 0) {
Code = pch::DECL_FUNCTION_TEMPLATE;
}
-void PCHDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
VisitTypeDecl(D);
Record.push_back(D->wasDeclaredWithTypename());
Code = pch::DECL_TEMPLATE_TYPE_PARM;
}
-void PCHDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
+void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
VisitVarDecl(D);
// TemplateParmPosition.
Record.push_back(D->getDepth());
Code = pch::DECL_NON_TYPE_TEMPLATE_PARM;
}
-void PCHDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
+void ASTDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
VisitTemplateDecl(D);
// TemplateParmPosition.
Record.push_back(D->getDepth());
Code = pch::DECL_TEMPLATE_TEMPLATE_PARM;
}
-void PCHDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) {
+void ASTDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) {
VisitDecl(D);
Writer.AddStmt(D->getAssertExpr());
Writer.AddStmt(D->getMessage());
/// that there are no declarations visible from this context. Note
/// that this value will not be emitted for non-primary declaration
/// contexts.
-void PCHDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
+void ASTDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
uint64_t VisibleOffset) {
Record.push_back(LexicalOffset);
Record.push_back(VisibleOffset);
}
template <typename T>
-void PCHDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
+void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
enum { NoRedeclaration = 0, PointsToPrevious, PointsToLatest };
if (D->RedeclLink.getNext() == D) {
Record.push_back(NoRedeclaration);
T *ThisDecl = static_cast<T*>(D);
// If this is a most recent redeclaration that is pointed to by a first decl
// in a chained PCH, keep track of the association with the map so we can
- // update the first decl during PCH reading.
+ // update the first decl during AST reading.
if (ThisDecl != First && First->getMostRecentDeclaration() == ThisDecl &&
First->getPCHLevel() > ThisDecl->getPCHLevel()) {
assert(Writer.FirstLatestDecls.find(First) == Writer.FirstLatestDecls.end()
/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
/// consumers of the AST.
///
-/// Such decls will always be deserialized from the PCH file, so we would like
+/// Such decls will always be deserialized from the AST file, so we would like
/// this to be as restrictive as possible. Currently the predicate is driven by
/// code generation requirements, if other clients have a different notion of
/// what is "required" then we may have to consider an alternate scheme where
void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
RecordData Record;
- PCHDeclWriter W(*this, Context, Record);
+ ASTDeclWriter W(*this, Context, Record);
// If this declaration is also a DeclContext, write blocks for the
// declarations that lexically stored inside its context and those
FlushStmts();
// Note "external" declarations so that we can add them to a record in the
- // PCH file later.
+ // AST file later.
//
// FIXME: This should be renamed, the predicate is much more complicated.
if (isRequiredDecl(D, Context))
//===----------------------------------------------------------------------===//
namespace clang {
- class PCHStmtWriter : public StmtVisitor<PCHStmtWriter, void> {
+ class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
ASTWriter &Writer;
ASTWriter::RecordData &Record;
public:
pch::StmtCode Code;
- PCHStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
+ ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
: Writer(Writer), Record(Record) { }
void
};
}
-void PCHStmtWriter::
+void ASTStmtWriter::
AddExplicitTemplateArgumentList(const ExplicitTemplateArgumentList &Args) {
Writer.AddSourceLocation(Args.LAngleLoc, Record);
Writer.AddSourceLocation(Args.RAngleLoc, Record);
Writer.AddTemplateArgumentLoc(Args.getTemplateArgs()[i], Record);
}
-void PCHStmtWriter::VisitStmt(Stmt *S) {
+void ASTStmtWriter::VisitStmt(Stmt *S) {
}
-void PCHStmtWriter::VisitNullStmt(NullStmt *S) {
+void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getSemiLoc(), Record);
Code = pch::STMT_NULL;
}
-void PCHStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
+void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
VisitStmt(S);
Record.push_back(S->size());
for (CompoundStmt::body_iterator CS = S->body_begin(), CSEnd = S->body_end();
Code = pch::STMT_COMPOUND;
}
-void PCHStmtWriter::VisitSwitchCase(SwitchCase *S) {
+void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
VisitStmt(S);
Record.push_back(Writer.getSwitchCaseID(S));
}
-void PCHStmtWriter::VisitCaseStmt(CaseStmt *S) {
+void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
VisitSwitchCase(S);
Writer.AddStmt(S->getLHS());
Writer.AddStmt(S->getRHS());
Code = pch::STMT_CASE;
}
-void PCHStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
+void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
VisitSwitchCase(S);
Writer.AddStmt(S->getSubStmt());
Writer.AddSourceLocation(S->getDefaultLoc(), Record);
Code = pch::STMT_DEFAULT;
}
-void PCHStmtWriter::VisitLabelStmt(LabelStmt *S) {
+void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
VisitStmt(S);
Writer.AddIdentifierRef(S->getID(), Record);
Writer.AddStmt(S->getSubStmt());
Code = pch::STMT_LABEL;
}
-void PCHStmtWriter::VisitIfStmt(IfStmt *S) {
+void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
VisitStmt(S);
Writer.AddDeclRef(S->getConditionVariable(), Record);
Writer.AddStmt(S->getCond());
Code = pch::STMT_IF;
}
-void PCHStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
+void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
VisitStmt(S);
Writer.AddDeclRef(S->getConditionVariable(), Record);
Writer.AddStmt(S->getCond());
Code = pch::STMT_SWITCH;
}
-void PCHStmtWriter::VisitWhileStmt(WhileStmt *S) {
+void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
VisitStmt(S);
Writer.AddDeclRef(S->getConditionVariable(), Record);
Writer.AddStmt(S->getCond());
Code = pch::STMT_WHILE;
}
-void PCHStmtWriter::VisitDoStmt(DoStmt *S) {
+void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
VisitStmt(S);
Writer.AddStmt(S->getCond());
Writer.AddStmt(S->getBody());
Code = pch::STMT_DO;
}
-void PCHStmtWriter::VisitForStmt(ForStmt *S) {
+void ASTStmtWriter::VisitForStmt(ForStmt *S) {
VisitStmt(S);
Writer.AddStmt(S->getInit());
Writer.AddStmt(S->getCond());
Code = pch::STMT_FOR;
}
-void PCHStmtWriter::VisitGotoStmt(GotoStmt *S) {
+void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
VisitStmt(S);
Record.push_back(Writer.GetLabelID(S->getLabel()));
Writer.AddSourceLocation(S->getGotoLoc(), Record);
Code = pch::STMT_GOTO;
}
-void PCHStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
+void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getGotoLoc(), Record);
Writer.AddSourceLocation(S->getStarLoc(), Record);
Code = pch::STMT_INDIRECT_GOTO;
}
-void PCHStmtWriter::VisitContinueStmt(ContinueStmt *S) {
+void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getContinueLoc(), Record);
Code = pch::STMT_CONTINUE;
}
-void PCHStmtWriter::VisitBreakStmt(BreakStmt *S) {
+void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getBreakLoc(), Record);
Code = pch::STMT_BREAK;
}
-void PCHStmtWriter::VisitReturnStmt(ReturnStmt *S) {
+void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
VisitStmt(S);
Writer.AddStmt(S->getRetValue());
Writer.AddSourceLocation(S->getReturnLoc(), Record);
Code = pch::STMT_RETURN;
}
-void PCHStmtWriter::VisitDeclStmt(DeclStmt *S) {
+void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getStartLoc(), Record);
Writer.AddSourceLocation(S->getEndLoc(), Record);
Code = pch::STMT_DECL;
}
-void PCHStmtWriter::VisitAsmStmt(AsmStmt *S) {
+void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) {
VisitStmt(S);
Record.push_back(S->getNumOutputs());
Record.push_back(S->getNumInputs());
Code = pch::STMT_ASM;
}
-void PCHStmtWriter::VisitExpr(Expr *E) {
+void ASTStmtWriter::VisitExpr(Expr *E) {
VisitStmt(E);
Writer.AddTypeRef(E->getType(), Record);
Record.push_back(E->isTypeDependent());
Record.push_back(E->isValueDependent());
}
-void PCHStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
+void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLocation(), Record);
Record.push_back(E->getIdentType()); // FIXME: stable encoding
Code = pch::EXPR_PREDEFINED;
}
-void PCHStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
+void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
VisitExpr(E);
Record.push_back(E->hasQualifier());
Code = pch::EXPR_DECL_REF;
}
-void PCHStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
+void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLocation(), Record);
Writer.AddAPInt(E->getValue(), Record);
Code = pch::EXPR_INTEGER_LITERAL;
}
-void PCHStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
+void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
VisitExpr(E);
Writer.AddAPFloat(E->getValue(), Record);
Record.push_back(E->isExact());
Code = pch::EXPR_FLOATING_LITERAL;
}
-void PCHStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
+void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
VisitExpr(E);
Writer.AddStmt(E->getSubExpr());
Code = pch::EXPR_IMAGINARY_LITERAL;
}
-void PCHStmtWriter::VisitStringLiteral(StringLiteral *E) {
+void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
VisitExpr(E);
Record.push_back(E->getByteLength());
Record.push_back(E->getNumConcatenated());
// FIXME: String data should be stored as a blob at the end of the
// StringLiteral. However, we can't do so now because we have no
// provision for coping with abbreviations when we're jumping around
- // the PCH file during deserialization.
+ // the AST file during deserialization.
Record.append(E->getString().begin(), E->getString().end());
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Writer.AddSourceLocation(E->getStrTokenLoc(I), Record);
Code = pch::EXPR_STRING_LITERAL;
}
-void PCHStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
+void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
VisitExpr(E);
Record.push_back(E->getValue());
Writer.AddSourceLocation(E->getLocation(), Record);
Code = pch::EXPR_CHARACTER_LITERAL;
}
-void PCHStmtWriter::VisitParenExpr(ParenExpr *E) {
+void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLParen(), Record);
Writer.AddSourceLocation(E->getRParen(), Record);
Code = pch::EXPR_PAREN;
}
-void PCHStmtWriter::VisitParenListExpr(ParenListExpr *E) {
+void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) {
VisitExpr(E);
Record.push_back(E->NumExprs);
for (unsigned i=0; i != E->NumExprs; ++i)
Code = pch::EXPR_PAREN_LIST;
}
-void PCHStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
+void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
Writer.AddStmt(E->getSubExpr());
Record.push_back(E->getOpcode()); // FIXME: stable encoding
Code = pch::EXPR_UNARY_OPERATOR;
}
-void PCHStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
+void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumComponents());
Record.push_back(E->getNumExpressions());
Code = pch::EXPR_OFFSETOF;
}
-void PCHStmtWriter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
+void ASTStmtWriter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
VisitExpr(E);
Record.push_back(E->isSizeOf());
if (E->isArgumentType())
Code = pch::EXPR_SIZEOF_ALIGN_OF;
}
-void PCHStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
+void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getLHS());
Writer.AddStmt(E->getRHS());
Code = pch::EXPR_ARRAY_SUBSCRIPT;
}
-void PCHStmtWriter::VisitCallExpr(CallExpr *E) {
+void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumArgs());
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_CALL;
}
-void PCHStmtWriter::VisitMemberExpr(MemberExpr *E) {
+void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
// Don't call VisitExpr, we'll write everything here.
Record.push_back(E->hasQualifier());
Code = pch::EXPR_MEMBER;
}
-void PCHStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
+void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getBase());
Writer.AddSourceLocation(E->getIsaMemberLoc(), Record);
Code = pch::EXPR_OBJC_ISA;
}
-void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
+void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
Record.push_back(E->path_size());
Writer.AddStmt(E->getSubExpr());
Writer.AddCXXBaseSpecifier(**PI, Record);
}
-void PCHStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
+void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
VisitExpr(E);
Writer.AddStmt(E->getLHS());
Writer.AddStmt(E->getRHS());
Code = pch::EXPR_BINARY_OPERATOR;
}
-void PCHStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
+void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
VisitBinaryOperator(E);
Writer.AddTypeRef(E->getComputationLHSType(), Record);
Writer.AddTypeRef(E->getComputationResultType(), Record);
Code = pch::EXPR_COMPOUND_ASSIGN_OPERATOR;
}
-void PCHStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
+void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
VisitExpr(E);
Writer.AddStmt(E->getCond());
Writer.AddStmt(E->getLHS());
Code = pch::EXPR_CONDITIONAL_OPERATOR;
}
-void PCHStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
+void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
VisitCastExpr(E);
Record.push_back(E->getCategory());
Code = pch::EXPR_IMPLICIT_CAST;
}
-void PCHStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
+void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
VisitCastExpr(E);
Writer.AddTypeSourceInfo(E->getTypeInfoAsWritten(), Record);
}
-void PCHStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
+void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
VisitExplicitCastExpr(E);
Writer.AddSourceLocation(E->getLParenLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_CSTYLE_CAST;
}
-void PCHStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
+void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLParenLoc(), Record);
Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
Code = pch::EXPR_COMPOUND_LITERAL;
}
-void PCHStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
+void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getBase());
Writer.AddIdentifierRef(&E->getAccessor(), Record);
Code = pch::EXPR_EXT_VECTOR_ELEMENT;
}
-void PCHStmtWriter::VisitInitListExpr(InitListExpr *E) {
+void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumInits());
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
Code = pch::EXPR_INIT_LIST;
}
-void PCHStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
+void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumSubExprs());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
Code = pch::EXPR_DESIGNATED_INIT;
}
-void PCHStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
+void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
VisitExpr(E);
Code = pch::EXPR_IMPLICIT_VALUE_INIT;
}
-void PCHStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
+void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getSubExpr());
Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
Code = pch::EXPR_VA_ARG;
}
-void PCHStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
+void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getAmpAmpLoc(), Record);
Writer.AddSourceLocation(E->getLabelLoc(), Record);
Code = pch::EXPR_ADDR_LABEL;
}
-void PCHStmtWriter::VisitStmtExpr(StmtExpr *E) {
+void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getSubStmt());
Writer.AddSourceLocation(E->getLParenLoc(), Record);
Code = pch::EXPR_STMT;
}
-void PCHStmtWriter::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
+void ASTStmtWriter::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
VisitExpr(E);
Writer.AddTypeSourceInfo(E->getArgTInfo1(), Record);
Writer.AddTypeSourceInfo(E->getArgTInfo2(), Record);
Code = pch::EXPR_TYPES_COMPATIBLE;
}
-void PCHStmtWriter::VisitChooseExpr(ChooseExpr *E) {
+void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getCond());
Writer.AddStmt(E->getLHS());
Code = pch::EXPR_CHOOSE;
}
-void PCHStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
+void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getTokenLocation(), Record);
Code = pch::EXPR_GNU_NULL;
}
-void PCHStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
+void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumSubExprs());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
Code = pch::EXPR_SHUFFLE_VECTOR;
}
-void PCHStmtWriter::VisitBlockExpr(BlockExpr *E) {
+void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
VisitExpr(E);
Writer.AddDeclRef(E->getBlockDecl(), Record);
Record.push_back(E->hasBlockDeclRefExprs());
Code = pch::EXPR_BLOCK;
}
-void PCHStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
+void ASTStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
VisitExpr(E);
Writer.AddDeclRef(E->getDecl(), Record);
Writer.AddSourceLocation(E->getLocation(), Record);
// Objective-C Expressions and Statements.
//===----------------------------------------------------------------------===//
-void PCHStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
+void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
VisitExpr(E);
Writer.AddStmt(E->getString());
Writer.AddSourceLocation(E->getAtLoc(), Record);
Code = pch::EXPR_OBJC_STRING_LITERAL;
}
-void PCHStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
+void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
VisitExpr(E);
Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record);
Writer.AddSourceLocation(E->getAtLoc(), Record);
Code = pch::EXPR_OBJC_ENCODE;
}
-void PCHStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
+void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
VisitExpr(E);
Writer.AddSelectorRef(E->getSelector(), Record);
Writer.AddSourceLocation(E->getAtLoc(), Record);
Code = pch::EXPR_OBJC_SELECTOR_EXPR;
}
-void PCHStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
+void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
VisitExpr(E);
Writer.AddDeclRef(E->getProtocol(), Record);
Writer.AddSourceLocation(E->getAtLoc(), Record);
Code = pch::EXPR_OBJC_PROTOCOL_EXPR;
}
-void PCHStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
+void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
VisitExpr(E);
Writer.AddDeclRef(E->getDecl(), Record);
Writer.AddSourceLocation(E->getLocation(), Record);
Code = pch::EXPR_OBJC_IVAR_REF_EXPR;
}
-void PCHStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
+void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
VisitExpr(E);
Writer.AddDeclRef(E->getProperty(), Record);
Writer.AddSourceLocation(E->getLocation(), Record);
Code = pch::EXPR_OBJC_PROPERTY_REF_EXPR;
}
-void PCHStmtWriter::VisitObjCImplicitSetterGetterRefExpr(
+void ASTStmtWriter::VisitObjCImplicitSetterGetterRefExpr(
ObjCImplicitSetterGetterRefExpr *E) {
VisitExpr(E);
Writer.AddDeclRef(E->getGetterMethod(), Record);
Code = pch::EXPR_OBJC_KVC_REF_EXPR;
}
-void PCHStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
+void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumArgs());
Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding
Code = pch::EXPR_OBJC_MESSAGE_EXPR;
}
-void PCHStmtWriter::VisitObjCSuperExpr(ObjCSuperExpr *E) {
+void ASTStmtWriter::VisitObjCSuperExpr(ObjCSuperExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLoc(), Record);
Code = pch::EXPR_OBJC_SUPER_EXPR;
}
-void PCHStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
+void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
VisitStmt(S);
Writer.AddStmt(S->getElement());
Writer.AddStmt(S->getCollection());
Code = pch::STMT_OBJC_FOR_COLLECTION;
}
-void PCHStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
+void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Writer.AddStmt(S->getCatchBody());
Writer.AddDeclRef(S->getCatchParamDecl(), Record);
Writer.AddSourceLocation(S->getAtCatchLoc(), Record);
Code = pch::STMT_OBJC_CATCH;
}
-void PCHStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
+void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Writer.AddStmt(S->getFinallyBody());
Writer.AddSourceLocation(S->getAtFinallyLoc(), Record);
Code = pch::STMT_OBJC_FINALLY;
}
-void PCHStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
+void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Record.push_back(S->getNumCatchStmts());
Record.push_back(S->getFinallyStmt() != 0);
Writer.AddStmt(S->getTryBody());
Code = pch::STMT_OBJC_AT_TRY;
}
-void PCHStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
+void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Writer.AddStmt(S->getSynchExpr());
Writer.AddStmt(S->getSynchBody());
Writer.AddSourceLocation(S->getAtSynchronizedLoc(), Record);
Code = pch::STMT_OBJC_AT_SYNCHRONIZED;
}
-void PCHStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
+void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Writer.AddStmt(S->getThrowExpr());
Writer.AddSourceLocation(S->getThrowLoc(), Record);
Code = pch::STMT_OBJC_AT_THROW;
// C++ Expressions and Statements.
//===----------------------------------------------------------------------===//
-void PCHStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
+void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getCatchLoc(), Record);
Writer.AddDeclRef(S->getExceptionDecl(), Record);
Code = pch::STMT_CXX_CATCH;
}
-void PCHStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
+void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
VisitStmt(S);
Record.push_back(S->getNumHandlers());
Writer.AddSourceLocation(S->getTryLoc(), Record);
Code = pch::STMT_CXX_TRY;
}
-void PCHStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
VisitCallExpr(E);
Record.push_back(E->getOperator());
Code = pch::EXPR_CXX_OPERATOR_CALL;
}
-void PCHStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
+void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
VisitCallExpr(E);
Code = pch::EXPR_CXX_MEMBER_CALL;
}
-void PCHStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
+void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumArgs());
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Code = pch::EXPR_CXX_CONSTRUCT;
}
-void PCHStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
+void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
VisitCXXConstructExpr(E);
Writer.AddSourceLocation(E->getTypeBeginLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_CXX_TEMPORARY_OBJECT;
}
-void PCHStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
+void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
VisitExplicitCastExpr(E);
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
}
-void PCHStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
+void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
VisitCXXNamedCastExpr(E);
Code = pch::EXPR_CXX_STATIC_CAST;
}
-void PCHStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
+void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
VisitCXXNamedCastExpr(E);
Code = pch::EXPR_CXX_DYNAMIC_CAST;
}
-void PCHStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
+void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
VisitCXXNamedCastExpr(E);
Code = pch::EXPR_CXX_REINTERPRET_CAST;
}
-void PCHStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
+void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
VisitCXXNamedCastExpr(E);
Code = pch::EXPR_CXX_CONST_CAST;
}
-void PCHStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
+void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
VisitExplicitCastExpr(E);
Writer.AddSourceLocation(E->getTypeBeginLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_CXX_FUNCTIONAL_CAST;
}
-void PCHStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
+void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
VisitExpr(E);
Record.push_back(E->getValue());
Writer.AddSourceLocation(E->getLocation(), Record);
Code = pch::EXPR_CXX_BOOL_LITERAL;
}
-void PCHStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
+void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLocation(), Record);
Code = pch::EXPR_CXX_NULL_PTR_LITERAL;
}
-void PCHStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
+void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
VisitExpr(E);
Writer.AddSourceRange(E->getSourceRange(), Record);
if (E->isTypeOperand()) {
}
}
-void PCHStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
+void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLocation(), Record);
Record.push_back(E->isImplicit());
Code = pch::EXPR_CXX_THIS;
}
-void PCHStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
+void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getThrowLoc(), Record);
Writer.AddStmt(E->getSubExpr());
Code = pch::EXPR_CXX_THROW;
}
-void PCHStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
VisitExpr(E);
bool HasOtherExprStored = E->Param.getInt();
Code = pch::EXPR_CXX_DEFAULT_ARG;
}
-void PCHStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
+void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
VisitExpr(E);
Writer.AddCXXTemporary(E->getTemporary(), Record);
Writer.AddStmt(E->getSubExpr());
Code = pch::EXPR_CXX_BIND_TEMPORARY;
}
-void PCHStmtWriter::VisitCXXBindReferenceExpr(CXXBindReferenceExpr *E) {
+void ASTStmtWriter::VisitCXXBindReferenceExpr(CXXBindReferenceExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getSubExpr());
Record.push_back(E->extendsLifetime());
Code = pch::EXPR_CXX_BIND_REFERENCE;
}
-void PCHStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
+void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getTypeBeginLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_CXX_SCALAR_VALUE_INIT;
}
-void PCHStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
+void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
VisitExpr(E);
Record.push_back(E->isGlobalNew());
Record.push_back(E->hasInitializer());
Code = pch::EXPR_CXX_NEW;
}
-void PCHStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
+void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
VisitExpr(E);
Record.push_back(E->isGlobalDelete());
Record.push_back(E->isArrayForm());
Code = pch::EXPR_CXX_DELETE;
}
-void PCHStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
+void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getBase());
Code = pch::EXPR_CXX_PSEUDO_DESTRUCTOR;
}
-void PCHStmtWriter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
+void ASTStmtWriter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
VisitExpr(E);
Record.push_back(E->getNumTemporaries());
for (unsigned i = 0, e = E->getNumTemporaries(); i != e; ++i)
}
void
-PCHStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
+ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
VisitExpr(E);
// Don't emit anything here, NumTemplateArgs must be emitted first.
const ExplicitTemplateArgumentList &Args
= *E->getExplicitTemplateArgumentList();
assert(Args.NumTemplateArgs &&
- "Num of template args was zero! PCH reading will mess up!");
+ "Num of template args was zero! AST reading will mess up!");
Record.push_back(Args.NumTemplateArgs);
AddExplicitTemplateArgumentList(Args);
} else {
}
void
-PCHStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
+ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
VisitExpr(E);
// Don't emit anything here, NumTemplateArgs must be emitted first.
if (E->hasExplicitTemplateArgs()) {
const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
assert(Args.NumTemplateArgs &&
- "Num of template args was zero! PCH reading will mess up!");
+ "Num of template args was zero! AST reading will mess up!");
Record.push_back(Args.NumTemplateArgs);
AddExplicitTemplateArgumentList(Args);
} else {
}
void
-PCHStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
+ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
VisitExpr(E);
Record.push_back(E->arg_size());
for (CXXUnresolvedConstructExpr::arg_iterator
Code = pch::EXPR_CXX_UNRESOLVED_CONSTRUCT;
}
-void PCHStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
+void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
VisitExpr(E);
// Don't emit anything here, NumTemplateArgs must be emitted first.
if (E->hasExplicitTemplateArgs()) {
const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
assert(Args.NumTemplateArgs &&
- "Num of template args was zero! PCH reading will mess up!");
+ "Num of template args was zero! AST reading will mess up!");
Record.push_back(Args.NumTemplateArgs);
AddExplicitTemplateArgumentList(Args);
} else {
Writer.AddSourceLocation(E->getNameLoc(), Record);
}
-void PCHStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
+void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
VisitOverloadExpr(E);
Record.push_back(E->isArrow());
Record.push_back(E->hasUnresolvedUsing());
Code = pch::EXPR_CXX_UNRESOLVED_MEMBER;
}
-void PCHStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
VisitOverloadExpr(E);
Record.push_back(E->requiresADL());
Record.push_back(E->isOverloaded());
Code = pch::EXPR_CXX_UNRESOLVED_LOOKUP;
}
-void PCHStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
+void ASTStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
VisitExpr(E);
Record.push_back(E->getTrait());
Writer.AddSourceRange(E->getSourceRange(), Record);
/// bitstream.
void ASTWriter::WriteSubStmt(Stmt *S) {
RecordData Record;
- PCHStmtWriter Writer(*this, Record);
+ ASTStmtWriter Writer(*this, Record);
++NumStatements;
if (!S) {
SourceManager &SrcMgr
= DeclIDs.begin()->first->getASTContext().getSourceManager();
S->dump(SrcMgr);
- assert(0 && "Unhandled sub statement writing PCH file");
+ assert(0 && "Unhandled sub statement writing AST file");
}
#endif