aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-03-10 17:45:58 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-03-10 17:45:58 +0000
commita16e9ac1f192503038f49e0c52edd7dcb2ce023a (patch)
tree56c1dd85a159948815817b5a90bedb39cf9ad105 /lib/Frontend
parentdd5132ce2569a1ef901c92772eb8581aa1705f25 (diff)
downloadsrc-a16e9ac1f192503038f49e0c52edd7dcb2ce023a.tar.gz
src-a16e9ac1f192503038f49e0c52edd7dcb2ce023a.zip
Notes
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/CacheTokens.cpp4
-rw-r--r--lib/Frontend/CompilerInstance.cpp4
-rw-r--r--lib/Frontend/DeclXML.cpp26
-rw-r--r--lib/Frontend/DependencyFile.cpp3
-rw-r--r--lib/Frontend/FrontendAction.cpp2
-rw-r--r--lib/Frontend/InitHeaderSearch.cpp2
-rw-r--r--lib/Frontend/PCHReader.cpp37
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp3
-rw-r--r--lib/Frontend/PCHReaderStmt.cpp5
-rw-r--r--lib/Frontend/PCHWriter.cpp9
-rw-r--r--lib/Frontend/PCHWriterDecl.cpp1
-rw-r--r--lib/Frontend/PCHWriterStmt.cpp5
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp8
13 files changed, 71 insertions, 38 deletions
diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp
index 702c1d0025d9..c845d56f4ec1 100644
--- a/lib/Frontend/CacheTokens.cpp
+++ b/lib/Frontend/CacheTokens.cpp
@@ -64,7 +64,7 @@ public:
PTHEntryKeyVariant(struct stat* statbuf, const char* path)
: Path(path), Kind(IsDE), StatBuf(new struct stat(*statbuf)) {}
- PTHEntryKeyVariant(const char* path)
+ explicit PTHEntryKeyVariant(const char* path)
: Path(path), Kind(IsNoExist), StatBuf(0) {}
bool isFile() const { return Kind == IsFE; }
@@ -513,7 +513,7 @@ public:
int result = StatSysCallCache::stat(path, buf);
if (result != 0) // Failed 'stat'.
- PM.insert(path, PTHEntry());
+ PM.insert(PTHEntryKeyVariant(path), PTHEntry());
else if (S_ISDIR(buf->st_mode)) {
// Only cache directories with absolute paths.
if (!llvm::sys::Path(path).isAbsolute())
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 1831ca532beb..25b804aba7fc 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -94,7 +94,7 @@ namespace {
public:
explicit BinaryDiagnosticSerializer(llvm::raw_ostream &OS)
: OS(OS), SourceMgr(0) { }
-
+
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
const DiagnosticInfo &Info);
};
@@ -341,7 +341,7 @@ void CompilerInstance::addOutputFile(llvm::StringRef Path,
OutputFiles.push_back(std::make_pair(Path, OS));
}
-void CompilerInstance::ClearOutputFiles(bool EraseFiles) {
+void CompilerInstance::clearOutputFiles(bool EraseFiles) {
for (std::list< std::pair<std::string, llvm::raw_ostream*> >::iterator
it = OutputFiles.begin(), ie = OutputFiles.end(); it != ie; ++it) {
delete it->second;
diff --git a/lib/Frontend/DeclXML.cpp b/lib/Frontend/DeclXML.cpp
index d7470d92a946..8750b1efcab5 100644
--- a/lib/Frontend/DeclXML.cpp
+++ b/lib/Frontend/DeclXML.cpp
@@ -29,6 +29,14 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter> {
}
}
+ void addFunctionBody(FunctionDecl* FD) {
+ if (FD->isThisDeclarationADefinition()) {
+ Doc.addSubNode("Body");
+ Doc.PrintStmt(FD->getBody());
+ Doc.toParent();
+ }
+ }
+
void addSubNodes(RecordDecl* RD) {
for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
@@ -37,6 +45,15 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter> {
}
}
+ void addSubNodes(CXXRecordDecl* RD) {
+ addSubNodes(cast<RecordDecl>(RD));
+ for (CXXRecordDecl::method_iterator i = RD->method_begin(),
+ e = RD->method_end(); i != e; ++i) {
+ Visit(*i);
+ Doc.toParent();
+ }
+ }
+
void addSubNodes(EnumDecl* ED) {
for (EnumDecl::enumerator_iterator i = ED->enumerator_begin(),
e = ED->enumerator_end(); i != e; ++i) {
@@ -115,6 +132,8 @@ public:
#define SUB_NODE_SEQUENCE_XML( CLASS ) addSubNodes(T);
#define SUB_NODE_OPT_XML( CLASS ) addSubNodes(T);
+#define SUB_NODE_FN_BODY_XML addFunctionBody(T);
+
#include "clang/Frontend/DeclXML.def"
};
@@ -122,13 +141,6 @@ public:
//---------------------------------------------------------
void DocumentXML::writeDeclToXML(Decl *D) {
DeclPrinter(*this).Visit(D);
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
- if (Stmt *Body = FD->getBody()) {
- addSubNode("Body");
- PrintStmt(Body);
- toParent();
- }
- }
toParent();
}
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp
index 478c33939cd7..de2b056dc7ce 100644
--- a/lib/Frontend/DependencyFile.cpp
+++ b/lib/Frontend/DependencyFile.cpp
@@ -74,8 +74,7 @@ void clang::AttachDependencyFileGen(Preprocessor &PP,
return;
}
- assert(!PP.getPPCallbacks() && "Preprocessor callbacks already registered!");
- PP.setPPCallbacks(new DependencyFileCallback(&PP, OS, Opts));
+ PP.addPPCallbacks(new DependencyFileCallback(&PP, OS, Opts));
}
/// FileMatchesDepCriteria - Determine whether the given Filename should be
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 96a68c931e1f..66df7a61917b 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/lib/Frontend/FrontendAction.cpp
@@ -180,7 +180,7 @@ void FrontendAction::EndSourceFile() {
// Cleanup the output streams, and erase the output files if we encountered
// an error.
- CI.ClearOutputFiles(/*EraseFiles=*/CI.getDiagnostics().getNumErrors());
+ CI.clearOutputFiles(/*EraseFiles=*/CI.getDiagnostics().getNumErrors());
// Inform the diagnostic client we are done with this source file.
CI.getDiagnosticClient().EndSourceFile();
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 4f972f0baff3..cd749d221db6 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -436,7 +436,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple) {
break;
}
- AddPath("/usr/local/include", System, false, false, false);
+ AddPath("/usr/local/include", System, true, false, false);
AddPath("/usr/include", System, false, false, false);
}
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index a878df784005..267f4c158508 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -120,7 +120,7 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) {
PARSE_LANGOPT_IMPORTANT(OpenCL, diag::warn_pch_opencl);
PARSE_LANGOPT_BENIGN(CatchUndefined);
PARSE_LANGOPT_IMPORTANT(ElideConstructors, diag::warn_pch_elide_constructors);
-#undef PARSE_LANGOPT_IRRELEVANT
+#undef PARSE_LANGOPT_IMPORTANT
#undef PARSE_LANGOPT_BENIGN
return false;
@@ -1089,13 +1089,13 @@ void PCHReader::ReadDefinedMacros() {
// If there was no preprocessor block, do nothing.
if (!MacroCursor.getBitStreamReader())
return;
-
+
llvm::BitstreamCursor Cursor = MacroCursor;
if (Cursor.EnterSubBlock(pch::PREPROCESSOR_BLOCK_ID)) {
Error("malformed preprocessor block record in PCH file");
return;
}
-
+
RecordData Record;
while (true) {
unsigned Code = Cursor.ReadCode();
@@ -1104,7 +1104,7 @@ void PCHReader::ReadDefinedMacros() {
Error("error at end of preprocessor block in PCH file");
return;
}
-
+
if (Code == llvm::bitc::ENTER_SUBBLOCK) {
// No known subblocks, always skip them.
Cursor.ReadSubBlockID();
@@ -1114,12 +1114,12 @@ void PCHReader::ReadDefinedMacros() {
}
continue;
}
-
+
if (Code == llvm::bitc::DEFINE_ABBREV) {
Cursor.ReadAbbrevRecord();
continue;
}
-
+
// Read a record.
const char *BlobStart;
unsigned BlobLen;
@@ -1127,7 +1127,7 @@ void PCHReader::ReadDefinedMacros() {
switch (Cursor.ReadRecord(Code, Record, &BlobStart, &BlobLen)) {
default: // Default behavior: ignore.
break;
-
+
case pch::PP_MACRO_OBJECT_LIKE:
case pch::PP_MACRO_FUNCTION_LIKE:
DecodeIdentifierInfo(Record[0]);
@@ -1339,7 +1339,7 @@ PCHReader::ReadPCHBlock() {
}
UnusedStaticFuncs.swap(Record);
break;
-
+
case pch::LOCALLY_SCOPED_EXTERNAL_DECLS:
if (!LocallyScopedExternalDecls.empty()) {
Error("duplicate LOCALLY_SCOPED_EXTERNAL_DECLS record in PCH file");
@@ -1385,7 +1385,7 @@ PCHReader::ReadPCHBlock() {
break;
case pch::STAT_CACHE: {
- PCHStatCache *MyStatCache =
+ PCHStatCache *MyStatCache =
new PCHStatCache((const unsigned char *)BlobStart + Record[0],
(const unsigned char *)BlobStart,
NumStatHits, NumStatMisses);
@@ -1393,7 +1393,7 @@ PCHReader::ReadPCHBlock() {
StatCache = MyStatCache;
break;
}
-
+
case pch::EXT_VECTOR_DECLS:
if (!ExtVectorDecls.empty()) {
Error("duplicate EXT_VECTOR_DECLS record in PCH file");
@@ -1412,7 +1412,7 @@ PCHReader::ReadPCHBlock() {
Comments = (SourceRange *)BlobStart;
NumComments = BlobLen / sizeof(SourceRange);
break;
-
+
case pch::VERSION_CONTROL_BRANCH_REVISION: {
const std::string &CurBranch = getClangFullRepositoryVersion();
llvm::StringRef PCHBranch(BlobStart, BlobLen);
@@ -1561,7 +1561,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
PP->getIdentifierTable().setExternalIdentifierLookup(this);
PP->getHeaderSearchInfo().SetExternalLookup(this);
PP->setExternalSource(this);
-
+
// Load the translation unit declaration
ReadDeclRecord(DeclOffsets[0], 0);
@@ -2018,6 +2018,12 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
Context->getSubstTemplateTypeParmType(cast<TemplateTypeParmType>(Parm),
Replacement);
}
+
+ case pch::TYPE_INJECTED_CLASS_NAME: {
+ CXXRecordDecl *D = cast<CXXRecordDecl>(GetDecl(Record[0]));
+ QualType TST = GetType(Record[1]); // probably derivable
+ return Context->getInjectedClassNameType(D, TST);
+ }
}
// Suppress a GCC warning
return QualType();
@@ -2172,6 +2178,9 @@ void TypeLocReader::VisitTemplateSpecializationTypeLoc(
void TypeLocReader::VisitQualifiedNameTypeLoc(QualifiedNameTypeLoc TL) {
TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
+void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
+ TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+}
void TypeLocReader::VisitTypenameTypeLoc(TypenameTypeLoc TL) {
TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -2271,7 +2280,7 @@ PCHReader::GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
case TemplateArgument::Type:
return GetTypeSourceInfo(Record, Index);
case TemplateArgument::Template: {
- SourceLocation
+ SourceLocation
QualStart = SourceLocation::getFromRawEncoding(Record[Index++]),
QualEnd = SourceLocation::getFromRawEncoding(Record[Index++]),
TemplateNameLoc = SourceLocation::getFromRawEncoding(Record[Index++]);
@@ -2487,7 +2496,7 @@ void PCHReader::InitializeSema(Sema &S) {
VarDecl *Var = cast<VarDecl>(GetDecl(TentativeDefinitions[I]));
SemaObj->TentativeDefinitions.push_back(Var);
}
-
+
// If there were any unused static functions, deserialize them and add to
// Sema's list of unused static functions.
for (unsigned I = 0, N = UnusedStaticFuncs.size(); I != N; ++I) {
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index 356bd0726e52..a3f5eac480cd 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -211,6 +211,7 @@ void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
MD->setResultType(Reader.GetType(Record[Idx++]));
+ MD->setResultTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
unsigned NumParams = Record[Idx++];
llvm::SmallVector<ParmVarDecl *, 16> Params;
@@ -690,7 +691,7 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
break;
case pch::DECL_OBJC_METHOD:
D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(),
- Selector(), QualType(), 0);
+ Selector(), QualType(), 0, 0);
break;
case pch::DECL_OBJC_INTERFACE:
D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0);
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index d123694d699d..7b94805d3999 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -792,8 +792,9 @@ unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
cast_or_null<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1]));
if (!E->getReceiver()) {
ObjCMessageExpr::ClassInfo CI;
- CI.first = cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]));
- CI.second = Reader.GetIdentifierInfo(Record, Idx);
+ CI.Decl = cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]));
+ CI.Name = Reader.GetIdentifierInfo(Record, Idx);
+ CI.Loc = SourceLocation::getFromRawEncoding(Record[Idx++]);
E->setClassInfo(CI);
}
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 93af75468382..eed3cc1a5b3d 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -235,6 +235,12 @@ void PCHTypeWriter::VisitQualifiedNameType(const QualifiedNameType *T) {
assert(false && "Cannot serialize qualified name types");
}
+void PCHTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) {
+ Writer.AddDeclRef(T->getDecl(), Record);
+ Writer.AddTypeRef(T->getUnderlyingType(), Record);
+ Code = pch::TYPE_INJECTED_CLASS_NAME;
+}
+
void PCHTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
Record.push_back(T->getNumProtocols());
@@ -394,6 +400,9 @@ void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
void TypeLocWriter::VisitQualifiedNameTypeLoc(QualifiedNameTypeLoc TL) {
Writer.AddSourceLocation(TL.getNameLoc(), Record);
}
+void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
+ Writer.AddSourceLocation(TL.getNameLoc(), Record);
+}
void TypeLocWriter::VisitTypenameTypeLoc(TypenameTypeLoc TL) {
Writer.AddSourceLocation(TL.getNameLoc(), Record);
}
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index e776d32454d2..0774797463e0 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -210,6 +210,7 @@ void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
// FIXME: stable encoding for in/out/inout/bycopy/byref/oneway
Record.push_back(D->getObjCDeclQualifier());
Writer.AddTypeRef(D->getResultType(), Record);
+ Writer.AddTypeSourceInfo(D->getResultTypeSourceInfo(), Record);
Writer.AddSourceLocation(D->getLocEnd(), Record);
Record.push_back(D->param_size());
for (ObjCMethodDecl::param_iterator P = D->param_begin(),
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index a8cc9d6f4591..9a5417ca6102 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -720,8 +720,9 @@ void PCHStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
if (!E->getReceiver()) {
ObjCMessageExpr::ClassInfo CI = E->getClassInfo();
- Writer.AddDeclRef(CI.first, Record);
- Writer.AddIdentifierRef(CI.second, Record);
+ Writer.AddDeclRef(CI.Decl, Record);
+ Writer.AddIdentifierRef(CI.Name, Record);
+ Writer.AddSourceLocation(CI.Loc, Record);
}
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index 774372c86934..be5bb0dade87 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -52,7 +52,7 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
if (MI.isGNUVarargs())
OS << "..."; // #define foo(x...)
-
+
OS << ')';
}
@@ -102,7 +102,7 @@ public:
EmittedMacroOnThisLine = false;
FileType = SrcMgr::C_User;
Initialized = false;
-
+
// If we're in microsoft mode, use normal #line instead of line markers.
UseLineDirective = PP.getLangOptions().Microsoft;
}
@@ -150,7 +150,7 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
OS << '#' << ' ' << LineNo << ' ' << '"';
OS.write(&CurFilename[0], CurFilename.size());
OS << '"';
-
+
if (ExtraLen)
OS.write(Extra, ExtraLen);
@@ -492,7 +492,7 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS,
PP.AddPragmaHandler("GCC", new UnknownPragmaHandler("#pragma GCC",
Callbacks));
- PP.setPPCallbacks(Callbacks);
+ PP.addPPCallbacks(Callbacks);
// After we have configured the preprocessor, enter the main file.
PP.EnterMainSourceFile();