[cfe-commits] r69002 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/Frontend/PCHBitCodes.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Douglas Gregor
dgregor at apple.com
Mon Apr 13 15:49:26 PDT 2009
Author: dgregor
Date: Mon Apr 13 17:49:25 2009
New Revision: 69002
URL: http://llvm.org/viewvc/llvm-project?rev=69002&view=rev
Log:
Partial PCH support for FileScopeAsmDecl and BlockDecl. Both require
expression or statement serialization before we can test them.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=69002&r1=69001&r2=69002&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Apr 13 17:49:25 2009
@@ -1206,6 +1206,8 @@
const StringLiteral *getAsmString() const { return AsmString; }
StringLiteral *getAsmString() { return AsmString; }
+ void setAsmString(StringLiteral *Asm) { AsmString = Asm; }
+
static bool classof(const Decl *D) {
return D->getKind() == FileScopeAsm;
}
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=69002&r1=69001&r2=69002&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Mon Apr 13 17:49:25 2009
@@ -330,6 +330,10 @@
DECL_PARM_VAR,
/// \brief An OriginalParmVarDecl record.
DECL_ORIGINAL_PARM_VAR,
+ /// \brief A FileScopeAsmDecl record.
+ DECL_FILE_SCOPE_ASM,
+ /// \brief A BlockDecl record.
+ DECL_BLOCK,
/// \brief A record that stores the set of declarations that are
/// lexically stored within a given DeclContext.
///
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69002&r1=69001&r2=69002&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Mon Apr 13 17:49:25 2009
@@ -58,7 +58,8 @@
void VisitVarDecl(VarDecl *VD);
void VisitParmVarDecl(ParmVarDecl *PD);
void VisitOriginalParmVarDecl(OriginalParmVarDecl *PD);
-
+ void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
+ void VisitBlockDecl(BlockDecl *BD);
std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC);
};
}
@@ -177,6 +178,21 @@
PD->setOriginalType(Reader.GetType(Record[Idx++]));
}
+void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) {
+ VisitDecl(AD);
+ // FIXME: read asm string
+}
+
+void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) {
+ VisitDecl(BD);
+ unsigned NumParams = Record[Idx++];
+ llvm::SmallVector<ParmVarDecl *, 16> Params;
+ Params.reserve(NumParams);
+ for (unsigned I = 0; I != NumParams; ++I)
+ Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
+ BD->setParams(Reader.getContext(), &Params[0], NumParams);
+}
+
std::pair<uint64_t, uint64_t>
PCHDeclReader::VisitDeclContext(DeclContext *DC) {
uint64_t LexicalOffset = Record[Idx++];
@@ -1105,6 +1121,23 @@
break;
}
+ case pch::DECL_FILE_SCOPE_ASM: {
+ FileScopeAsmDecl *Asm = FileScopeAsmDecl::Create(Context, 0,
+ SourceLocation(), 0);
+ LoadedDecl(Index, Asm);
+ Reader.VisitFileScopeAsmDecl(Asm);
+ D = Asm;
+ break;
+ }
+
+ case pch::DECL_BLOCK: {
+ BlockDecl *Block = BlockDecl::Create(Context, 0, SourceLocation());
+ LoadedDecl(Index, Block);
+ Reader.VisitBlockDecl(Block);
+ D = Block;
+ break;
+ }
+
default:
assert(false && "Cannot de-serialize this kind of declaration");
break;
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69002&r1=69001&r2=69002&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Mon Apr 13 17:49:25 2009
@@ -262,6 +262,8 @@
void VisitVarDecl(VarDecl *D);
void VisitParmVarDecl(ParmVarDecl *D);
void VisitOriginalParmVarDecl(OriginalParmVarDecl *D);
+ void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
+ void VisitBlockDecl(BlockDecl *D);
void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
uint64_t VisibleOffset);
};
@@ -383,6 +385,22 @@
Code = pch::DECL_ORIGINAL_PARM_VAR;
}
+void PCHDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
+ VisitDecl(D);
+ // FIXME: Emit the string literal
+ Code = pch::DECL_FILE_SCOPE_ASM;
+}
+
+void PCHDeclWriter::VisitBlockDecl(BlockDecl *D) {
+ VisitDecl(D);
+ // FIXME: emit block body
+ Record.push_back(D->param_size());
+ for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();
+ P != PEnd; ++P)
+ Writer.AddDeclRef(*P, Record);
+ Code = pch::DECL_BLOCK;
+}
+
/// \brief Emit the DeclContext part of a declaration context decl.
///
/// \param LexicalOffset the offset at which the DECL_CONTEXT_LEXICAL
More information about the cfe-commits
mailing list