summaryrefslogtreecommitdiff
path: root/include/clang/Frontend
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
commit4c8b24812ddcd1dedaca343a6d4e76f91f398981 (patch)
tree137ebebcae16fb0ce7ab4af456992bbd8d22fced /include/clang/Frontend
parent5362a71c02e7d448a8ce98cf00c47e353fba5d04 (diff)
Notes
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h24
-rw-r--r--include/clang/Frontend/ASTUnit.h39
-rw-r--r--include/clang/Frontend/Analyses.def9
-rw-r--r--include/clang/Frontend/CommandLineSourceLoc.h29
-rw-r--r--include/clang/Frontend/CompileOptions.h2
-rw-r--r--include/clang/Frontend/DeclXML.def8
-rw-r--r--include/clang/Frontend/DocumentXML.h60
-rw-r--r--include/clang/Frontend/FixItRewriter.h4
-rw-r--r--include/clang/Frontend/FrontendDiagnostic.h2
-rw-r--r--include/clang/Frontend/InitHeaderSearch.h22
-rw-r--r--include/clang/Frontend/ManagerRegistry.h2
-rw-r--r--include/clang/Frontend/PCHBitCodes.h93
-rw-r--r--include/clang/Frontend/PCHReader.h155
-rw-r--r--include/clang/Frontend/PCHWriter.h69
-rw-r--r--include/clang/Frontend/PathDiagnosticClients.h36
-rw-r--r--include/clang/Frontend/StmtXML.def3
-rw-r--r--include/clang/Frontend/TextDiagnosticPrinter.h8
-rw-r--r--include/clang/Frontend/TypeXML.def21
-rw-r--r--include/clang/Frontend/Utils.h31
19 files changed, 383 insertions, 234 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index be45202625586..f59a0a7d481e6 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -14,11 +14,10 @@
#ifndef DRIVER_ASTCONSUMERS_H
#define DRIVER_ASTCONSUMERS_H
-#include "llvm/Support/raw_ostream.h"
#include <string>
-#include <iosfwd>
namespace llvm {
+ class raw_ostream;
class Module;
class LLVMContext;
namespace sys { class Path; }
@@ -30,20 +29,20 @@ class Diagnostic;
class FileManager;
class Preprocessor;
class PreprocessorFactory;
-struct CompileOptions;
+class CompileOptions;
class LangOptions;
// AST pretty-printer: prints out the AST in a format that is close to the
// original C code. The output is intended to be in a format such that
// clang could re-parse the output back into the same AST, but the
// implementation is still incomplete.
-ASTConsumer *CreateASTPrinter(llvm::raw_ostream* OS);
+ASTConsumer *CreateASTPrinter(llvm::raw_ostream *OS);
-// AST XML-printer: prints out the AST in a XML format
+// AST XML-printer: prints out the AST in a XML format
// The output is intended to be in a format such that
-// clang or any other tool could re-parse the output back into the same AST,
+// clang or any other tool could re-parse the output back into the same AST,
// but the implementation is still incomplete.
-ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream* OS);
+ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS);
// AST dumper: dumps the raw AST in human-readable form to stderr; this is
// intended for debugging.
@@ -58,10 +57,14 @@ ASTConsumer *CreateASTViewer();
// to stderr; this is intended for debugging.
ASTConsumer *CreateDeclContextPrinter();
+// RecordLayout dumper: prints out the record layout information for all records
+// in the translation unit; this is intended for debugging.
+ASTConsumer *CreateRecordLayoutDumper();
+
// ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code.
// This is considered experimental, and only works with Apple's ObjC runtime.
-ASTConsumer *CreateObjCRewriter(const std::string& InFile,
- llvm::raw_ostream* OS,
+ASTConsumer *CreateObjCRewriter(const std::string &InFile,
+ llvm::raw_ostream *OS,
Diagnostic &Diags,
const LangOptions &LOpts,
bool SilenceRewriteMacroWarning);
@@ -92,7 +95,8 @@ ASTConsumer* CreateHTMLPrinter(llvm::raw_ostream *OS, Diagnostic &D,
// used later with the PCHReader (clang-cc option -include-pch)
// to speed up compile times.
ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
- llvm::raw_ostream *OS);
+ llvm::raw_ostream *OS,
+ const char *isysroot = 0);
// Block rewriter: rewrites code using the Apple blocks extension to pure
// C code. Output is always sent to stdout.
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index 68c06f5dcee61..89eb3b8821ca0 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H
#define LLVM_CLANG_FRONTEND_ASTUNIT_H
+#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/OwningPtr.h"
#include <string>
@@ -21,7 +22,6 @@ namespace clang {
class FileManager;
class FileEntry;
class SourceManager;
- class DiagnosticClient;
class Diagnostic;
class HeaderSearch;
class TargetInfo;
@@ -32,40 +32,49 @@ namespace clang {
/// \brief Utility class for loading a ASTContext from a PCH file.
///
class ASTUnit {
- llvm::OwningPtr<SourceManager> SourceMgr;
- llvm::OwningPtr<DiagnosticClient> DiagClient;
- llvm::OwningPtr<Diagnostic> Diags;
+ Diagnostic &Diags;
+ SourceManager SourceMgr;
llvm::OwningPtr<HeaderSearch> HeaderInfo;
llvm::OwningPtr<TargetInfo> Target;
llvm::OwningPtr<Preprocessor> PP;
llvm::OwningPtr<ASTContext> Ctx;
- ASTUnit(const ASTUnit&); // do not implement
- ASTUnit &operator=(const ASTUnit &); // do not implement
- ASTUnit();
-
+ ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT
+ ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT
+ ASTUnit(Diagnostic &_Diag);
+
public:
~ASTUnit();
- const SourceManager &getSourceManager() const { return *SourceMgr.get(); }
- SourceManager &getSourceManager() { return *SourceMgr.get(); }
+ const SourceManager &getSourceManager() const { return SourceMgr; }
+ SourceManager &getSourceManager() { return SourceMgr; }
const Preprocessor &getPreprocessor() const { return *PP.get(); }
Preprocessor &getPreprocessor() { return *PP.get(); }
-
+
const ASTContext &getASTContext() const { return *Ctx.get(); }
ASTContext &getASTContext() { return *Ctx.get(); }
+ const Diagnostic &getDiagnostic() const { return Diags; }
+ Diagnostic &getDiagnostic() { return Diags; }
+
+ FileManager &getFileManager();
+ const std::string &getOriginalSourceFileName();
+
/// \brief Create a ASTUnit from a PCH file.
///
- /// \param Filename PCH filename
+ /// \param Filename - The PCH file to load.
+ ///
+ /// \param Diags - The Diagnostic implementation to use.
///
- /// \param FileMgr The FileManager to use
+ /// \param FileMgr - The FileManager to use.
///
- /// \param ErrMsg Error message to report if the PCH file could not be loaded
+ /// \param ErrMsg - Error message to report if the PCH file could not be
+ /// loaded.
///
- /// \returns the initialized ASTUnit or NULL if the PCH failed to load
+ /// \returns - The initialized ASTUnit or null if the PCH failed to load.
static ASTUnit *LoadFromPCHFile(const std::string &Filename,
+ Diagnostic &Diags,
FileManager &FileMgr,
std::string *ErrMsg = 0);
};
diff --git a/include/clang/Frontend/Analyses.def b/include/clang/Frontend/Analyses.def
index ad799c3a8b25b..d5e408020a987 100644
--- a/include/clang/Frontend/Analyses.def
+++ b/include/clang/Frontend/Analyses.def
@@ -24,6 +24,10 @@ ANALYSIS(CFGView, "cfg-view",
ANALYSIS(DisplayLiveVariables, "dump-live-variables",
"Print results of live variable analysis", Code)
+ANALYSIS(SecuritySyntacticChecks, "warn-security-syntactic",
+ "Perform quick security checks that require no data flow",
+ Code)
+
ANALYSIS(WarnDeadStores, "warn-dead-stores",
"Warn about stores to dead variables", Code)
@@ -44,6 +48,10 @@ ANALYSIS(WarnObjCUnusedIvars, "warn-objc-unused-ivars",
ANALYSIS(CheckerCFRef, "checker-cfref",
"Run the [Core] Foundation reference count checker", Code)
+ANALYSIS(InlineCall, "inline-call",
+ "Experimental transfer function inling callees when its definition"
+ " is available.", TranslationUnit)
+
#ifndef ANALYSIS_STORE
#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)
#endif
@@ -64,6 +72,7 @@ ANALYSIS_CONSTRAINTS(RangeConstraints, "range", "Use constraint tracking of conc
ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML", CreateHTMLDiagnosticClient, false)
ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", CreatePlistDiagnosticClient, true)
+ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", "Output analysis results using HTML wrapped with Plists", CreatePlistHTMLDiagnosticClient, true)
#undef ANALYSIS
#undef ANALYSIS_STORE
diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h
index 1eaa958995f54..59f70ede9129d 100644
--- a/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/include/clang/Frontend/CommandLineSourceLoc.h
@@ -34,46 +34,45 @@ namespace llvm {
///
/// Source locations are of the form filename:line:column.
template<>
- class parser<clang::ParsedSourceLocation>
+ class parser<clang::ParsedSourceLocation>
: public basic_parser<clang::ParsedSourceLocation> {
public:
- bool parse(Option &O, const char *ArgName,
- const std::string &ArgValue,
+ bool parse(Option &O, StringRef ArgName, StringRef ArgValue,
clang::ParsedSourceLocation &Val);
};
- bool
+ bool
parser<clang::ParsedSourceLocation>::
- parse(Option &O, const char *ArgName, const std::string &ArgValue,
+ parse(Option &O, StringRef ArgName, StringRef ArgValue,
clang::ParsedSourceLocation &Val) {
using namespace clang;
- const char *ExpectedFormat
+ const char *ExpectedFormat
= "source location must be of the form filename:line:column";
- std::string::size_type SecondColon = ArgValue.rfind(':');
+ StringRef::size_type SecondColon = ArgValue.rfind(':');
if (SecondColon == std::string::npos) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
- char *EndPtr;
- long Column
- = std::strtol(ArgValue.c_str() + SecondColon + 1, &EndPtr, 10);
- if (EndPtr != ArgValue.c_str() + ArgValue.size()) {
+
+ unsigned Column;
+ if (ArgValue.substr(SecondColon + 1).getAsInteger(10, Column)) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
+ ArgValue = ArgValue.substr(0, SecondColon);
- std::string::size_type FirstColon = ArgValue.rfind(':', SecondColon-1);
+ StringRef::size_type FirstColon = ArgValue.rfind(':');
if (FirstColon == std::string::npos) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
- long Line = std::strtol(ArgValue.c_str() + FirstColon + 1, &EndPtr, 10);
- if (EndPtr != ArgValue.c_str() + SecondColon) {
+ unsigned Line;
+ if (ArgValue.substr(FirstColon + 1).getAsInteger(10, Line)) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
-
+
Val.FileName = ArgValue.substr(0, FirstColon);
Val.Line = Line;
Val.Column = Column;
diff --git a/include/clang/Frontend/CompileOptions.h b/include/clang/Frontend/CompileOptions.h
index 75dec00f747f3..508af537b1fa1 100644
--- a/include/clang/Frontend/CompileOptions.h
+++ b/include/clang/Frontend/CompileOptions.h
@@ -67,7 +67,7 @@ public:
Inlining = NoInlining;
DisableRedZone = 0;
NoImplicitFloat = 0;
- }
+ }
};
} // end namespace clang
diff --git a/include/clang/Frontend/DeclXML.def b/include/clang/Frontend/DeclXML.def
index 956d9719f9f40..36323c260c9a3 100644
--- a/include/clang/Frontend/DeclXML.def
+++ b/include/clang/Frontend/DeclXML.def
@@ -91,8 +91,8 @@ NODE_XML(FunctionDecl, "Function")
ATTRIBUTE_FILE_LOCATION_XML
ATTRIBUTE_XML(getDeclContext(), "context")
ATTRIBUTE_XML(getNameAsString(), "name")
- TYPE_ATTRIBUTE_XML(getType()->getAsFunctionType()->getResultType())
- ATTRIBUTE_XML(getType()->getAsFunctionType(), "function_type")
+ TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
+ ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
ENUM_XML(FunctionDecl::None, "")
ENUM_XML(FunctionDecl::Extern, "extern")
@@ -111,8 +111,8 @@ NODE_XML(CXXMethodDecl, "CXXMethodDecl")
ATTRIBUTE_FILE_LOCATION_XML
ATTRIBUTE_XML(getDeclContext(), "context")
ATTRIBUTE_XML(getNameAsString(), "name")
- TYPE_ATTRIBUTE_XML(getType()->getAsFunctionType()->getResultType())
- ATTRIBUTE_XML(getType()->getAsFunctionType(), "function_type")
+ TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
+ ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
ATTRIBUTE_OPT_XML(isInline(), "inline")
ATTRIBUTE_OPT_XML(isStatic(), "static")
ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
diff --git a/include/clang/Frontend/DocumentXML.h b/include/clang/Frontend/DocumentXML.h
index 4ed11e153ce36..6693ddbac57d5 100644
--- a/include/clang/Frontend/DocumentXML.h
+++ b/include/clang/Frontend/DocumentXML.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the XML document class, which provides the means to
+// This file implements the XML document class, which provides the means to
// dump out the AST in a XML form that exposes type details and other fields.
//
//===----------------------------------------------------------------------===//
@@ -32,10 +32,9 @@ class NamedDecl;
class FunctionDecl;
class ASTContext;
class LabelStmt;
-
-//---------------------------------------------------------
-namespace XML
-{
+
+//---------------------------------------------------------
+namespace XML {
// id maps:
template<class T>
struct IdMap : llvm::DenseMap<T, unsigned> {};
@@ -47,9 +46,8 @@ namespace XML
struct IdMap<std::string> : std::map<std::string, unsigned> {};
}
-//---------------------------------------------------------
-class DocumentXML
-{
+//---------------------------------------------------------
+class DocumentXML {
public:
DocumentXML(const std::string& rootName, llvm::raw_ostream& out);
@@ -62,24 +60,22 @@ public:
DocumentXML& addSubNode(const std::string& name); // also enters the sub node, returns *this
DocumentXML& toParent(); // returns *this
- void addAttribute(const char* pName, const QualType& pType);
+ void addAttribute(const char* pName, const QualType& pType);
void addAttribute(const char* pName, bool value);
template<class T>
- void addAttribute(const char* pName, const T* value)
- {
+ void addAttribute(const char* pName, const T* value) {
addPtrAttribute(pName, value);
}
template<class T>
- void addAttribute(const char* pName, T* value)
- {
+ void addAttribute(const char* pName, T* value) {
addPtrAttribute(pName, value);
}
template<class T>
void addAttribute(const char* pName, const T& value);
-
+
template<class T>
void addAttributeOptional(const char* pName, const T& value);
@@ -114,7 +110,7 @@ private:
void Indent();
// forced pointer dispatch:
- void addPtrAttribute(const char* pName, const Type* pType);
+ void addPtrAttribute(const char* pName, const Type* pType);
void addPtrAttribute(const char* pName, const NamedDecl* D);
void addPtrAttribute(const char* pName, const DeclContext* D);
void addPtrAttribute(const char* pName, const NamespaceDecl* D); // disambiguation
@@ -136,47 +132,43 @@ private:
// for addAttributeOptional:
static bool isDefault(unsigned value) { return value == 0; }
static bool isDefault(bool value) { return !value; }
+ static bool isDefault(Qualifiers::GC value) { return value == Qualifiers::GCNone; }
static bool isDefault(const std::string& value) { return value.empty(); }
};
//--------------------------------------------------------- inlines
-inline void DocumentXML::initialize(ASTContext &Context)
-{
- Ctx = &Context;
+inline void DocumentXML::initialize(ASTContext &Context) {
+ Ctx = &Context;
}
-//---------------------------------------------------------
+//---------------------------------------------------------
template<class T>
-inline void DocumentXML::addAttribute(const char* pName, const T& value)
-{
+inline void DocumentXML::addAttribute(const char* pName, const T& value) {
Out << ' ' << pName << "=\"" << value << "\"";
}
-//---------------------------------------------------------
-inline void DocumentXML::addPtrAttribute(const char* pName, const char* text)
-{
+//---------------------------------------------------------
+inline void DocumentXML::addPtrAttribute(const char* pName, const char* text) {
Out << ' ' << pName << "=\"" << text << "\"";
}
-//---------------------------------------------------------
-inline void DocumentXML::addAttribute(const char* pName, bool value)
-{
+//---------------------------------------------------------
+inline void DocumentXML::addAttribute(const char* pName, bool value) {
addPtrAttribute(pName, value ? "1" : "0");
}
-//---------------------------------------------------------
+//---------------------------------------------------------
template<class T>
-inline void DocumentXML::addAttributeOptional(const char* pName, const T& value)
-{
- if (!isDefault(value))
- {
+inline void DocumentXML::addAttributeOptional(const char* pName,
+ const T& value) {
+ if (!isDefault(value)) {
addAttribute(pName, value);
}
}
-//---------------------------------------------------------
+//---------------------------------------------------------
-} //namespace clang
+} //namespace clang
#endif //LLVM_CLANG_DOCUMENTXML_H
diff --git a/include/clang/Frontend/FixItRewriter.h b/include/clang/Frontend/FixItRewriter.h
index 7fcd682bf66c1..fac87afadef24 100644
--- a/include/clang/Frontend/FixItRewriter.h
+++ b/include/clang/Frontend/FixItRewriter.h
@@ -51,7 +51,7 @@ class FixItRewriter : public DiagnosticClient {
unsigned NumFailures;
/// \brief Locations at which we should perform fix-its.
- ///
+ ///
/// When empty, perform fix-it modifications everywhere.
llvm::SmallVector<RequestedSourceLocation, 4> FixItLocations;
@@ -72,7 +72,7 @@ public:
/// \brief Write the modified source file.
///
/// \returns true if there was an error, false otherwise.
- bool WriteFixedFile(const std::string &InFileName,
+ bool WriteFixedFile(const std::string &InFileName,
const std::string &OutFileName = std::string());
/// IncludeInDiagnosticCounts - This method (whose default implementation
diff --git a/include/clang/Frontend/FrontendDiagnostic.h b/include/clang/Frontend/FrontendDiagnostic.h
index 079abae3eee1c..a044586a8c0a1 100644
--- a/include/clang/Frontend/FrontendDiagnostic.h
+++ b/include/clang/Frontend/FrontendDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define FRONTENDSTART
diff --git a/include/clang/Frontend/InitHeaderSearch.h b/include/clang/Frontend/InitHeaderSearch.h
index 51516661c99ef..a90b4eaf9e2b5 100644
--- a/include/clang/Frontend/InitHeaderSearch.h
+++ b/include/clang/Frontend/InitHeaderSearch.h
@@ -14,11 +14,12 @@
#ifndef LLVM_CLANG_FRONTEND_INIT_HEADER_SEARCH_H_
#define LLVM_CLANG_FRONTEND_INIT_HEADER_SEARCH_H_
+#include "clang/Lex/DirectoryLookup.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
#include <string>
#include <vector>
-#include "clang/Lex/DirectoryLookup.h"
-
namespace clang {
class HeaderSearch;
@@ -48,7 +49,7 @@ public:
: Headers(HS), Verbose(verbose), isysroot(iSysroot) {}
/// AddPath - Add the specified path to the specified group list.
- void AddPath(const std::string &Path, IncludeDirGroup Group,
+ void AddPath(const llvm::StringRef &Path, IncludeDirGroup Group,
bool isCXXAware, bool isUserSupplied,
bool isFramework, bool IgnoreSysRoot = false);
@@ -56,13 +57,26 @@ public:
/// header search list.
void AddEnvVarPaths(const char *Name);
+ /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to suport a gnu
+ /// libstdc++.
+ void AddGnuCPlusPlusIncludePaths(const std::string &Base, const char *Dir32,
+ const char *Dir64,
+ const llvm::Triple &triple);
+
+ /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to suport a MinGW
+ /// libstdc++.
+ void AddMinGWCPlusPlusIncludePaths(const std::string &Base,
+ const char *Arch,
+ const char *Version);
+
/// AddDefaultEnvVarPaths - Adds list of paths from default environment
/// variables such as CPATH.
void AddDefaultEnvVarPaths(const LangOptions &Lang);
/// AddDefaultSystemIncludePaths - Adds the default system include paths so
/// that e.g. stdio.h is found.
- void AddDefaultSystemIncludePaths(const LangOptions &Lang);
+ void AddDefaultSystemIncludePaths(const LangOptions &Lang,
+ const llvm::Triple &triple);
/// Realize - Merges all search path lists into one list and send it to
/// HeaderSearch.
diff --git a/include/clang/Frontend/ManagerRegistry.h b/include/clang/Frontend/ManagerRegistry.h
index ecab67a3b6769..f05cfe6df6b8d 100644
--- a/include/clang/Frontend/ManagerRegistry.h
+++ b/include/clang/Frontend/ManagerRegistry.h
@@ -43,7 +43,7 @@ public:
class RegisterConstraintManager {
public:
RegisterConstraintManager(ConstraintManagerCreator CMC) {
- assert(ManagerRegistry::ConstraintMgrCreator == 0
+ assert(ManagerRegistry::ConstraintMgrCreator == 0
&& "ConstraintMgrCreator already set!");
ManagerRegistry::ConstraintMgrCreator = CMC;
}
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
index 80aa248a78e6f..716780e68a528 100644
--- a/include/clang/Frontend/PCHBitCodes.h
+++ b/include/clang/Frontend/PCHBitCodes.h
@@ -29,7 +29,11 @@ namespace clang {
/// incompatible with previous versions (such that a reader
/// designed for the previous version could not support reading
/// the new version), this number should be increased.
- const unsigned VERSION_MAJOR = 1;
+ ///
+ /// Version 3 of PCH files also requires that the Subversion branch and
+ /// revision match exactly, since there is no backward compatibility of
+ /// PCH files at this time.
+ const unsigned VERSION_MAJOR = 3;
/// \brief PCH minor version number supported by this version of
/// Clang.
@@ -65,7 +69,7 @@ namespace clang {
typedef uint32_t IdentID;
typedef uint32_t SelectorID;
-
+
/// \brief Describes the various kinds of blocks that occur within
/// a PCH file.
enum BlockIDs {
@@ -106,7 +110,7 @@ namespace clang {
/// TYPE_OFFSET block to determine the offset of that type's
/// corresponding record within the TYPES_BLOCK_ID block.
TYPE_OFFSET = 1,
-
+
/// \brief Record code for the offsets of each decl.
///
/// The DECL_OFFSET constant describes the record that occurs
@@ -182,7 +186,7 @@ namespace clang {
/// \brief Record code for the array of locally-scoped external
/// declarations.
LOCALLY_SCOPED_EXTERNAL_DECLS = 11,
-
+
/// \brief Record code for the table of offsets into the
/// Objective-C method pool.
SELECTOR_OFFSETS = 12,
@@ -212,17 +216,17 @@ namespace clang {
/// \brief Record code for the set of ext_vector type names.
EXT_VECTOR_DECLS = 18,
- /// \brief Record code for the set of Objective-C category
- /// implementations.
- OBJC_CATEGORY_IMPLEMENTATIONS = 19,
-
/// \brief Record code for the original file that was used to
/// generate the precompiled header.
- ORIGINAL_FILE_NAME = 20,
-
+ ORIGINAL_FILE_NAME = 19,
+
/// \brief Record code for the sorted array of source ranges where
/// comments were encountered in the source code.
- COMMENT_RANGES = 21
+ COMMENT_RANGES = 20,
+
+ /// \brief Record code for the Subversion branch and revision information
+ /// of the compiler used to build this PCH file.
+ SVN_BRANCH_REVISION = 21
};
/// \brief Record types used within a source manager block.
@@ -247,7 +251,7 @@ namespace clang {
/// ControllingMacro is optional.
SM_HEADER_FILE_INFO = 6
};
-
+
/// \brief Record types used within a preprocessor block.
enum PreprocessorRecordTypes {
// The macros in the PP section are a PP_MACRO_* instance followed by a
@@ -261,7 +265,7 @@ namespace clang {
/// [PP_MACRO_FUNCTION_LIKE, <ObjectLikeStuff>, IsC99Varargs, IsGNUVarars,
/// NumArgs, ArgIdentInfoID* ]
PP_MACRO_FUNCTION_LIKE = 2,
-
+
/// \brief Describes one token.
/// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags]
PP_TOKEN = 3
@@ -329,7 +333,15 @@ namespace clang {
/// \brief The '__int128_t' type.
PREDEF_TYPE_INT128_ID = 22,
/// \brief The type of 'nullptr'.
- PREDEF_TYPE_NULLPTR_ID = 23
+ PREDEF_TYPE_NULLPTR_ID = 23,
+ /// \brief The C++ 'char16_t' type.
+ PREDEF_TYPE_CHAR16_ID = 24,
+ /// \brief The C++ 'char32_t' type.
+ PREDEF_TYPE_CHAR32_ID = 25,
+ /// \brief The ObjC 'id' type.
+ PREDEF_TYPE_OBJC_ID = 26,
+ /// \brief The ObjC 'Class' type.
+ PREDEF_TYPE_OBJC_CLASS = 27
};
/// \brief The number of predefined type IDs that are reserved for
@@ -388,12 +400,18 @@ namespace clang {
TYPE_ENUM = 20,
/// \brief An ObjCInterfaceType record.
TYPE_OBJC_INTERFACE = 21,
- /// \brief An ObjCQualifiedInterfaceType record.
- TYPE_OBJC_QUALIFIED_INTERFACE = 22,
/// \brief An ObjCObjectPointerType record.
- TYPE_OBJC_OBJECT_POINTER = 23,
+ TYPE_OBJC_OBJECT_POINTER = 22,
+ /// \brief An ObjCProtocolListType record.
+ TYPE_OBJC_PROTOCOL_LIST = 23,
/// \brief a DecltypeType record.
- TYPE_DECLTYPE = 24
+ TYPE_DECLTYPE = 24,
+ /// \brief A ConstantArrayWithExprType record.
+ TYPE_CONSTANT_ARRAY_WITH_EXPR = 25,
+ /// \brief A ConstantArrayWithoutExprType record.
+ TYPE_CONSTANT_ARRAY_WITHOUT_EXPR = 26,
+ /// \brief An ElaboratedType record.
+ TYPE_ELABORATED = 27
};
/// \brief The type IDs for special types constructed by semantic
@@ -415,7 +433,17 @@ namespace clang {
/// \brief CFConstantString type
SPECIAL_TYPE_CF_CONSTANT_STRING = 5,
/// \brief Objective-C fast enumeration state type
- SPECIAL_TYPE_OBJC_FAST_ENUMERATION_STATE = 6
+ SPECIAL_TYPE_OBJC_FAST_ENUMERATION_STATE = 6,
+ /// \brief C FILE typedef type
+ SPECIAL_TYPE_FILE = 7,
+ /// \brief C jmp_buf typedef type
+ SPECIAL_TYPE_jmp_buf = 8,
+ /// \brief C sigjmp_buf typedef type
+ SPECIAL_TYPE_sigjmp_buf = 9,
+ /// \brief Objective-C "id" redefinition type
+ SPECIAL_TYPE_OBJC_ID_REDEFINITION = 10,
+ /// \brief Objective-C "Class" redefinition type
+ SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 11
};
/// \brief Record codes for each kind of declaration.
@@ -611,7 +639,7 @@ namespace clang {
EXPR_BLOCK_DECL_REF,
// Objective-C
-
+
/// \brief An ObjCStringLiteral record.
EXPR_OBJC_STRING_LITERAL,
/// \brief An ObjCEncodeExpr record.
@@ -624,25 +652,34 @@ namespace clang {
EXPR_OBJC_IVAR_REF_EXPR,
/// \brief An ObjCPropertyRefExpr record.
EXPR_OBJC_PROPERTY_REF_EXPR,
- /// \brief An ObjCKVCRefExpr record.
+ /// \brief An ObjCImplicitSetterGetterRefExpr record.
EXPR_OBJC_KVC_REF_EXPR,
/// \brief An ObjCMessageExpr record.
EXPR_OBJC_MESSAGE_EXPR,
/// \brief An ObjCSuperExpr record.
EXPR_OBJC_SUPER_EXPR,
+ /// \brief An ObjCIsa Expr record.
+ EXPR_OBJC_ISA,
- /// \brief An ObjCForCollectionStmt record.
+ /// \brief An ObjCForCollectionStmt record.
STMT_OBJC_FOR_COLLECTION,
- /// \brief An ObjCAtCatchStmt record.
+ /// \brief An ObjCAtCatchStmt record.
STMT_OBJC_CATCH,
- /// \brief An ObjCAtFinallyStmt record.
+ /// \brief An ObjCAtFinallyStmt record.
STMT_OBJC_FINALLY,
- /// \brief An ObjCAtTryStmt record.
+ /// \brief An ObjCAtTryStmt record.
STMT_OBJC_AT_TRY,
- /// \brief An ObjCAtSynchronizedStmt record.
+ /// \brief An ObjCAtSynchronizedStmt record.
STMT_OBJC_AT_SYNCHRONIZED,
- /// \brief An ObjCAtThrowStmt record.
- STMT_OBJC_AT_THROW
+ /// \brief An ObjCAtThrowStmt record.
+ STMT_OBJC_AT_THROW,
+
+ // C++
+
+ /// \brief A CXXOperatorCallExpr record.
+ EXPR_CXX_OPERATOR_CALL,
+ /// \brief A CXXConstructExpr record.
+ EXPR_CXX_CONSTRUCT
};
/// \brief The kinds of designators that can occur in a
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index 8291f4697a8ea..1230e3753e04d 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -30,6 +30,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Bitcode/BitstreamReader.h"
#include "llvm/Support/DataTypes.h"
+#include <deque>
#include <map>
#include <string>
#include <utility>
@@ -54,7 +55,7 @@ class Preprocessor;
class Sema;
class SwitchCase;
class PCHReader;
-class HeaderFileInfo;
+struct HeaderFileInfo;
/// \brief Abstract interface for callback invocations by the PCHReader.
///
@@ -65,21 +66,21 @@ class HeaderFileInfo;
class PCHReaderListener {
public:
virtual ~PCHReaderListener();
-
+
/// \brief Receives the language options.
///
/// \returns true to indicate the options are invalid or false otherwise.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts) {
return false;
}
-
+
/// \brief Receives the target triple.
///
/// \returns true to indicate the target triple is invalid or false otherwise.
virtual bool ReadTargetTriple(const std::string &Triple) {
return false;
}
-
+
/// \brief Receives the contents of the predefines buffer.
///
/// \param PCHPredef The start of the predefines buffer in the PCH
@@ -94,16 +95,16 @@ public:
/// here.
///
/// \returns true to indicate the predefines are invalid or false otherwise.
- virtual bool ReadPredefinesBuffer(const char *PCHPredef,
+ virtual bool ReadPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID,
std::string &SuggestedPredefines) {
return false;
}
-
+
/// \brief Receives a HeaderFileInfo entry.
virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI) {}
-
+
/// \brief Receives __COUNTER__ value.
virtual void ReadCounter(unsigned Value) {}
};
@@ -113,16 +114,16 @@ public:
class PCHValidator : public PCHReaderListener {
Preprocessor &PP;
PCHReader &Reader;
-
+
unsigned NumHeaderInfos;
-
+
public:
PCHValidator(Preprocessor &PP, PCHReader &Reader)
: PP(PP), Reader(Reader), NumHeaderInfos(0) {}
-
+
virtual bool ReadLanguageOptions(const LangOptions &LangOpts);
virtual bool ReadTargetTriple(const std::string &Triple);
- virtual bool ReadPredefinesBuffer(const char *PCHPredef,
+ virtual bool ReadPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID,
std::string &SuggestedPredefines);
@@ -142,8 +143,8 @@ public:
/// The PCH reader provides lazy de-serialization of declarations, as
/// required when traversing the AST. Only those AST nodes that are
/// actually required will be de-serialized.
-class PCHReader
- : public ExternalSemaSource,
+class PCHReader
+ : public ExternalSemaSource,
public IdentifierInfoLookup,
public ExternalIdentifierLookup,
public ExternalSLocEntrySource {
@@ -153,11 +154,11 @@ public:
private:
/// \ brief The receiver of some callbacks invoked by PCHReader.
llvm::OwningPtr<PCHReaderListener> Listener;
-
+
SourceManager &SourceMgr;
FileManager &FileMgr;
Diagnostic &Diags;
-
+
/// \brief The semantic analysis object that will be processing the
/// PCH file and the translation unit that uses it.
Sema *SemaObj;
@@ -202,10 +203,10 @@ private:
const uint32_t *TypeOffsets;
/// \brief Types that have already been loaded from the PCH file.
- ///
- /// When the pointer at index I is non-NULL, the type with
+ ///
+ /// When the pointer at index I is non-NULL, the type with
/// ID = (I + 1) << 3 has already been loaded from the PCH file.
- std::vector<Type *> TypesLoaded;
+ std::vector<QualType> TypesLoaded;
/// \brief Offset of each declaration within the bitstream, indexed
/// by the declaration ID (-1).
@@ -272,7 +273,7 @@ private:
/// \brief The total number of selectors stored in the PCH file.
unsigned TotalNumSelectors;
- /// \brief A vector containing selectors that have already been loaded.
+ /// \brief A vector containing selectors that have already been loaded.
///
/// This vector is indexed by the Selector ID (-1). NULL selector
/// entries indicate that the particular selector ID has not yet
@@ -281,10 +282,10 @@ private:
/// \brief A sorted array of source ranges containing comments.
SourceRange *Comments;
-
+
/// \brief The number of source ranges in the Comments array.
unsigned NumComments;
-
+
/// \brief The set of external definitions stored in the the PCH
/// file.
llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
@@ -309,6 +310,13 @@ private:
/// file.
std::string OriginalFileName;
+ /// \brief Whether this precompiled header is a relocatable PCH file.
+ bool RelocatablePCH;
+
+ /// \brief The system include root to be used when loading the
+ /// precompiled header.
+ const char *isysroot;
+
/// \brief Mapping from switch-case IDs in the PCH file to
/// switch-case statements.
std::map<unsigned, SwitchCase *> SwitchCaseStmts;
@@ -362,6 +370,40 @@ private:
/// Number of visible decl contexts read/total.
unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
+ /// \brief When a type or declaration is being loaded from the PCH file, an
+ /// instantance of this RAII object will be available on the stack to
+ /// indicate when we are in a recursive-loading situation.
+ class LoadingTypeOrDecl {
+ PCHReader &Reader;
+ LoadingTypeOrDecl *Parent;
+
+ LoadingTypeOrDecl(const LoadingTypeOrDecl&); // do not implement
+ LoadingTypeOrDecl &operator=(const LoadingTypeOrDecl&); // do not implement
+
+ public:
+ explicit LoadingTypeOrDecl(PCHReader &Reader);
+ ~LoadingTypeOrDecl();
+ };
+ friend class LoadingTypeOrDecl;
+
+ /// \brief If we are currently loading a type or declaration, points to the
+ /// most recent LoadingTypeOrDecl object on the stack.
+ LoadingTypeOrDecl *CurrentlyLoadingTypeOrDecl;
+
+ /// \brief An IdentifierInfo that has been loaded but whose top-level
+ /// declarations of the same name have not (yet) been loaded.
+ struct PendingIdentifierInfo {
+ IdentifierInfo *II;
+ llvm::SmallVector<uint32_t, 4> DeclIDs;
+ };
+
+ /// \brief The set of identifiers that were read while the PCH reader was
+ /// (recursively) loading declarations.
+ ///
+ /// The declarations on the identifier chain for these identifiers will be
+ /// loaded once the recursive loading has completed.
+ std::deque<PendingIdentifierInfo> PendingIdentifierInfos;
+
/// \brief FIXME: document!
llvm::SmallVector<uint64_t, 4> SpecialTypes;
@@ -392,14 +434,17 @@ private:
/// there are differences that the PCH reader can work around, this
/// predefines buffer may contain additional definitions.
std::string SuggestedPredefines;
-
+
+ void MaybeAddSystemRootToFilename(std::string &Filename);
+
PCHReadResult ReadPCHBlock();
- bool CheckPredefinesBuffer(const char *PCHPredef,
+ bool CheckPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID);
+ bool ParseLineTable(llvm::SmallVectorImpl<uint64_t> &Record);
PCHReadResult ReadSourceManagerBlock();
PCHReadResult ReadSLocEntryRecord(unsigned ID);
-
+
bool ParseLanguageOptions(const llvm::SmallVectorImpl<uint64_t> &Record);
QualType ReadTypeRecord(uint64_t Offset);
void LoadedDecl(unsigned Index, Decl *D);
@@ -413,39 +458,62 @@ private:
PCHReader(const PCHReader&); // do not implement
PCHReader &operator=(const PCHReader &); // do not implement
-
public:
typedef llvm::SmallVector<uint64_t, 64> RecordData;
/// \brief Load the PCH file and validate its contents against the given
/// Preprocessor.
- PCHReader(Preprocessor &PP, ASTContext *Context);
-
+ ///
+ /// \param PP the preprocessor associated with the context in which this
+ /// precompiled header will be loaded.
+ ///
+ /// \param Context the AST context that this precompiled header will be
+ /// loaded into.
+ ///
+ /// \param isysroot If non-NULL, the system include path specified by the
+ /// user. This is only used with relocatable PCH files. If non-NULL,
+ /// a relocatable PCH file will use the default path "/".
+ PCHReader(Preprocessor &PP, ASTContext *Context, const char *isysroot = 0);
+
/// \brief Load the PCH file without using any pre-initialized Preprocessor.
///
/// The necessary information to initialize a Preprocessor later can be
/// obtained by setting a PCHReaderListener.
- PCHReader(SourceManager &SourceMgr, FileManager &FileMgr, Diagnostic &Diags);
+ ///
+ /// \param SourceMgr the source manager into which the precompiled header
+ /// will be loaded.
+ ///
+ /// \param FileMgr the file manager into which the precompiled header will
+ /// be loaded.
+ ///
+ /// \param Diags the diagnostics system to use for reporting errors and
+ /// warnings relevant to loading the precompiled header.
+ ///
+ /// \param isysroot If non-NULL, the system include path specified by the
+ /// user. This is only used with relocatable PCH files. If non-NULL,
+ /// a relocatable PCH file will use the default path "/".
+ PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
+ Diagnostic &Diags, const char *isysroot = 0);
~PCHReader();
/// \brief Load the precompiled header designated by the given file
/// name.
PCHReadResult ReadPCH(const std::string &FileName);
-
+
/// \brief Set the PCH callbacks listener.
void setListener(PCHReaderListener *listener) {
Listener.reset(listener);
}
-
+
/// \brief Set the Preprocessor to use.
void setPreprocessor(Preprocessor &pp) {
PP = &pp;
}
-
+
/// \brief Sets and initializes the given Context.
void InitializeContext(ASTContext &Context);
- /// \brief Retrieve the name of the original source file name
+ /// \brief Retrieve the name of the original source file name
const std::string &getOriginalSourceFile() { return OriginalFileName; }
/// \brief Retrieve the name of the original source file name
@@ -465,7 +533,7 @@ public:
/// replaced with the sorted set of source ranges corresponding to
/// comments in the source code.
virtual void ReadComments(std::vector<SourceRange> &Comments);
-
+
/// \brief Resolve a type ID into a type, potentially building a new
/// type.
virtual QualType GetType(pch::TypeID ID);
@@ -551,10 +619,13 @@ public:
///
/// \returns a pair of Objective-C methods lists containing the
/// instance and factory methods, respectively, with this selector.
- virtual std::pair<ObjCMethodList, ObjCMethodList>
+ virtual std::pair<ObjCMethodList, ObjCMethodList>
ReadMethodPool(Selector Sel);
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II);
+ void SetGloballyVisibleDecls(IdentifierInfo *II,
+ const llvm::SmallVectorImpl<uint32_t> &DeclIDs,
+ bool Nonrecursive = false);
/// \brief Report a diagnostic.
DiagnosticBuilder Diag(unsigned DiagID);
@@ -563,11 +634,11 @@ public:
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
IdentifierInfo *DecodeIdentifierInfo(unsigned Idx);
-
+
IdentifierInfo *GetIdentifierInfo(const RecordData &Record, unsigned &Idx) {
return DecodeIdentifierInfo(Record[Idx++]);
}
-
+
virtual IdentifierInfo *GetIdentifier(unsigned ID) {
return DecodeIdentifierInfo(ID);
}
@@ -576,7 +647,7 @@ public:
virtual void ReadSLocEntry(unsigned ID);
Selector DecodeSelector(unsigned Idx);
-
+
Selector GetSelector(const RecordData &Record, unsigned &Idx) {
return DecodeSelector(Record[Idx++]);
}
@@ -599,13 +670,13 @@ public:
/// \brief ReadDeclExpr - Reads an expression from the current decl cursor.
Expr *ReadDeclExpr();
-
+
/// \brief ReadTypeExpr - Reads an expression from the current type cursor.
Expr *ReadTypeExpr();
/// \brief Reads a statement from the specified cursor.
Stmt *ReadStmt(llvm::BitstreamCursor &Cursor);
-
+
/// \brief Read a statement from the current DeclCursor.
Stmt *ReadDeclStmt() {
return ReadStmt(DeclsCursor);
@@ -670,16 +741,16 @@ public:
struct SavedStreamPosition {
explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
: Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
-
+
~SavedStreamPosition() {
Cursor.JumpToBit(Offset);
}
-
+
private:
llvm::BitstreamCursor &Cursor;
uint64_t Offset;
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h
index c663442e64d8c..a807cd7c4d1fa 100644
--- a/include/clang/Frontend/PCHWriter.h
+++ b/include/clang/Frontend/PCHWriter.h
@@ -40,6 +40,24 @@ class SourceManager;
class SwitchCase;
class TargetInfo;
+/// A structure for putting "fast"-unqualified QualTypes into a
+/// DenseMap. This uses the standard pointer hash function.
+struct UnsafeQualTypeDenseMapInfo {
+ static inline bool isEqual(QualType A, QualType B) { return A == B; }
+ static inline bool isPod() { return true; }
+ static inline QualType getEmptyKey() {
+ return QualType::getFromOpaquePtr((void*) 1);
+ }
+ static inline QualType getTombstoneKey() {
+ return QualType::getFromOpaquePtr((void*) 2);
+ }
+ static inline unsigned getHashValue(QualType T) {
+ assert(!T.getFastQualifiers() && "hash invalid for types with fast quals");
+ uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
+ return (unsigned(v) >> 4) ^ (unsigned(v) >> 9);
+ }
+};
+
/// \brief Writes a precompiled header containing the contents of a
/// translation unit.
///
@@ -76,9 +94,11 @@ private:
///
/// The ID numbers of types are consecutive (in order of discovery)
/// and start at 1. 0 is reserved for NULL. When types are actually
- /// stored in the stream, the ID number is shifted by 3 bits to
- /// allow for the const/volatile/restrict qualifiers.
- llvm::DenseMap<const Type *, pch::TypeID> TypeIDs;
+ /// stored in the stream, the ID number is shifted by 2 bits to
+ /// allow for the const/volatile qualifiers.
+ ///
+ /// Keys in the map never have const/volatile qualifiers.
+ llvm::DenseMap<QualType, pch::TypeID, UnsafeQualTypeDenseMapInfo> TypeIDs;
/// \brief Offset of each type in the bitstream, indexed by
/// the type's ID.
@@ -89,7 +109,7 @@ private:
/// \brief Queue containing the types that we still need to
/// emit.
- std::queue<const Type *> TypesToEmit;
+ std::queue<QualType> TypesToEmit;
/// \brief Map that provides the ID numbers of each identifier in
/// the output stream.
@@ -98,21 +118,21 @@ private:
/// discovery), starting at 1. An ID of zero refers to a NULL
/// IdentifierInfo.
llvm::DenseMap<const IdentifierInfo *, pch::IdentID> IdentifierIDs;
-
+
/// \brief Offsets of each of the identifier IDs into the identifier
/// table.
std::vector<uint32_t> IdentifierOffsets;
/// \brief Map that provides the ID numbers of each Selector.
llvm::DenseMap<Selector, pch::SelectorID> SelectorIDs;
-
+
/// \brief Offset of each selector within the method pool/selector
/// table, indexed by the Selector ID (-1).
std::vector<uint32_t> SelectorOffsets;
/// \brief A vector of all Selectors (ordered by ID).
std::vector<Selector> SelVector;
-
+
/// \brief Offsets of each of the macro identifiers into the
/// bitstream.
///
@@ -141,7 +161,7 @@ private:
/// \brief Mapping from SwitchCase statements to IDs.
std::map<SwitchCase *, unsigned> SwitchCaseIDs;
-
+
/// \brief Mapping from LabelStmt statements to IDs.
std::map<LabelStmt *, unsigned> LabelIDs;
@@ -160,18 +180,19 @@ private:
unsigned NumVisibleDeclContexts;
void WriteBlockInfoBlock();
- void WriteMetadata(ASTContext &Context);
+ void WriteMetadata(ASTContext &Context, const char *isysroot);
void WriteLanguageOptions(const LangOptions &LangOpts);
- void WriteStatCache(MemorizeStatCalls &StatCalls);
- void WriteSourceManagerBlock(SourceManager &SourceMgr,
- const Preprocessor &PP);
+ void WriteStatCache(MemorizeStatCalls &StatCalls, const char* isysroot);
+ void WriteSourceManagerBlock(SourceManager &SourceMgr,
+ const Preprocessor &PP,
+ const char* isysroot);
void WritePreprocessor(const Preprocessor &PP);
void WriteComments(ASTContext &Context);
- void WriteType(const Type *T);
+ void WriteType(QualType T);
void WriteTypesBlock(ASTContext &Context);
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
-
+
void WriteDeclsBlock(ASTContext &Context);
void WriteMethodPool(Sema &SemaRef);
void WriteIdentifierTable(Preprocessor &PP);
@@ -179,14 +200,24 @@ private:
unsigned ParmVarDeclAbbrev;
void WriteDeclsBlockAbbrevs();
-
+
public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
PCHWriter(llvm::BitstreamWriter &Stream);
-
+
/// \brief Write a precompiled header for the given semantic analysis.
- void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls);
+ ///
+ /// \param SemaRef a reference to the semantic analysis object that processed
+ /// the AST to be written into the precompiled header.
+ ///
+ /// \param StatCalls the object that cached all of the stat() calls made while
+ /// searching for source files and headers.
+ ///
+ /// \param isysroot if non-NULL, write a relocatable PCH file whose headers
+ /// are relative to the given system root.
+ void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
+ const char* isysroot);
/// \brief Emit a source location.
void AddSourceLocation(SourceLocation Loc, RecordData &Record);
@@ -205,7 +236,7 @@ public:
/// \brief Emit a Selector (which is a smart pointer reference)
void AddSelectorRef(const Selector, RecordData &Record);
-
+
/// \brief Get the unique number used to refer to the given
/// identifier.
pch::IdentID getIdentifierRef(const IdentifierInfo *II);
@@ -215,7 +246,7 @@ public:
///
/// The identifier must refer to a macro.
uint64_t getMacroOffset(const IdentifierInfo *II) {
- assert(MacroOffsets.find(II) != MacroOffsets.end() &&
+ assert(MacroOffsets.find(II) != MacroOffsets.end() &&
"Identifier does not name a macro");
return MacroOffsets[II];
}
diff --git a/include/clang/Frontend/PathDiagnosticClients.h b/include/clang/Frontend/PathDiagnosticClients.h
index 028cd8549272d..8cb6898d75984 100644
--- a/include/clang/Frontend/PathDiagnosticClients.h
+++ b/include/clang/Frontend/PathDiagnosticClients.h
@@ -14,7 +14,9 @@
#ifndef LLVM_CLANG_FRONTEND_PATH_DIAGNOSTIC_CLIENTS_H
#define LLVM_CLANG_FRONTEND_PATH_DIAGNOSTIC_CLiENTS_H
+#include <memory>
#include <string>
+#include "llvm/ADT/SmallVector.h"
namespace clang {
@@ -22,13 +24,31 @@ class PathDiagnosticClient;
class Preprocessor;
class PreprocessorFactory;
-PathDiagnosticClient* CreateHTMLDiagnosticClient(const std::string& prefix,
- Preprocessor* PP = 0,
- PreprocessorFactory* PPF = 0);
-
-PathDiagnosticClient* CreatePlistDiagnosticClient(const std::string& prefix,
- Preprocessor* PP,
- PreprocessorFactory* PPF);
-}
+class PathDiagnosticClientFactory {
+public:
+ PathDiagnosticClientFactory() {}
+ virtual ~PathDiagnosticClientFactory() {}
+ virtual const char *getName() const = 0;
+
+ virtual PathDiagnosticClient*
+ createPathDiagnosticClient(llvm::SmallVectorImpl<std::string> *FilesMade) = 0;
+};
+
+PathDiagnosticClient*
+CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP = 0,
+ PreprocessorFactory* PPF = 0,
+ llvm::SmallVectorImpl<std::string>* FilesMade = 0);
+
+PathDiagnosticClientFactory*
+CreateHTMLDiagnosticClientFactory(const std::string& prefix,
+ Preprocessor* PP = 0,
+ PreprocessorFactory* PPF = 0);
+
+PathDiagnosticClient*
+CreatePlistDiagnosticClient(const std::string& prefix, Preprocessor* PP,
+ PreprocessorFactory* PPF,
+ PathDiagnosticClientFactory *PF = 0);
+
+} // end clang namespace
#endif
diff --git a/include/clang/Frontend/StmtXML.def b/include/clang/Frontend/StmtXML.def
index 26430f740d91d..fd79cf0c6ccbd 100644
--- a/include/clang/Frontend/StmtXML.def
+++ b/include/clang/Frontend/StmtXML.def
@@ -78,6 +78,9 @@
# define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context")
#endif
+NODE_XML(Stmt, "Stmt_Unsupported") // fallback for unsupproted statements
+ ATTRIBUTE_FILE_LOCATION_XML
+END_NODE_XML
NODE_XML(NullStmt, "NullStmt")
ATTRIBUTE_FILE_LOCATION_XML
diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h
index f8408bdbd742e..0fd8d44f72bc1 100644
--- a/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -52,7 +52,7 @@ public:
unsigned messageLength = 0,
bool useColors = false)
: OS(os), LangOpts(0),
- LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
+ LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation),
PrintRangeInfo(printRangeInfo),
PrintDiagnosticOption(printDiagnosticOption),
@@ -63,7 +63,7 @@ public:
void setLangOptions(const LangOptions *LO) {
LangOpts = LO;
}
-
+
void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM);
void HighlightRange(const SourceRange &R,
@@ -72,13 +72,13 @@ public:
std::string &CaretLine,
const std::string &SourceLine);
- void EmitCaretDiagnostic(SourceLocation Loc,
+ void EmitCaretDiagnostic(SourceLocation Loc,
SourceRange *Ranges, unsigned NumRanges,
SourceManager &SM,
const CodeModificationHint *Hints,
unsigned NumHints,
unsigned Columns);
-
+
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
const DiagnosticInfo &Info);
};
diff --git a/include/clang/Frontend/TypeXML.def b/include/clang/Frontend/TypeXML.def
index 2a78fd9f75b12..6aca15a75427c 100644
--- a/include/clang/Frontend/TypeXML.def
+++ b/include/clang/Frontend/TypeXML.def
@@ -68,17 +68,8 @@ NODE_XML(QualType, "CvQualifiedType")
ATTRIBUTE_OPT_XML(isConstQualified(), "const") // boolean
ATTRIBUTE_OPT_XML(isVolatileQualified(), "volatile") // boolean
ATTRIBUTE_OPT_XML(isRestrictQualified(), "restrict") // boolean
-END_NODE_XML
-
-NODE_XML(ExtQualType, "ExtQualType")
- ID_ATTRIBUTE_XML
- TYPE_ATTRIBUTE_XML(getBaseType())
- ATTRIBUTE_OPT_XML(getAddressSpace(), "adress_space") // unsigned: Address Space ID - The address space ID this type is qualified with.
- ATTRIBUTE_ENUM_OPT_XML(getObjCGCAttr(), "objc_gc") // GC __weak/__strong attributes
- ENUM_XML(QualType::GCNone, "")
- ENUM_XML(QualType::Weak, "weak")
- ENUM_XML(QualType::Strong, "strong")
- END_ENUM_XML
+ ATTRIBUTE_OPT_XML(getObjCGCAttr(), "objc_gc") // Qualifiers::GC
+ ATTRIBUTE_OPT_XML(getAddressSpace(), "address_space") // unsigned
END_NODE_XML
NODE_XML(BuiltinType, "FundamentalType")
@@ -104,6 +95,8 @@ NODE_XML(BuiltinType, "FundamentalType")
ENUM_XML(BuiltinType::Double, "double");
ENUM_XML(BuiltinType::LongDouble, "long double");
ENUM_XML(BuiltinType::WChar, "wchar_t");
+ ENUM_XML(BuiltinType::Char16, "char16_t");
+ ENUM_XML(BuiltinType::Char32, "char32_t");
ENUM_XML(BuiltinType::NullPtr, "nullptr_t"); // This is the type of C++0x 'nullptr'.
ENUM_XML(BuiltinType::Overload, "overloaded");
ENUM_XML(BuiltinType::Dependent, "dependent");
@@ -173,7 +166,7 @@ NODE_XML(ConstantArrayType, "ArrayType")
ENUM_XML(ArrayType::Static, "static")
ENUM_XML(ArrayType::Star, "star")
END_ENUM_XML
- ATTRIBUTE_OPT_XML(getIndexTypeQualifier(), "index_type_qualifier") // unsigned
+ ATTRIBUTE_OPT_XML(getIndexTypeCVRQualifiers(), "index_type_qualifier") // unsigned
END_NODE_XML
NODE_XML(IncompleteArrayType, "IncompleteArrayType")
@@ -254,10 +247,6 @@ NODE_XML(ObjCInterfaceType, "ObjCInterfaceType")
ID_ATTRIBUTE_XML
END_NODE_XML
-NODE_XML(ObjCQualifiedInterfaceType, "ObjCQualifiedInterfaceType")
- ID_ATTRIBUTE_XML
-END_NODE_XML
-
NODE_XML(ObjCObjectPointerType, "ObjCObjectPointerType")
ID_ATTRIBUTE_XML
END_NODE_XML
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 77df60cd7210a..9cbcf8e3e93e8 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -34,8 +34,6 @@ class PreprocessorFactory;
class LangOptions;
class Decl;
class Stmt;
-class ASTContext;
-class SourceLocation;
/// ProcessWarningOptions - Initialize the diagnostic client and process the
/// warning options specified on the command line.
@@ -59,7 +57,7 @@ void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS);
/// RewriteMacrosInInput - A simple test for the TokenRewriter class.
void DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS);
-
+
/// CreatePrintParserActionsAction - Return the actions implementation that
/// implements the -parse-print-callbacks option.
MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP,
@@ -78,33 +76,6 @@ void AttachDependencyFileGen(Preprocessor *PP, llvm::raw_ostream *OS,
/// a seekable stream.
void CacheTokens(Preprocessor& PP, llvm::raw_fd_ostream* OS);
-/// \brief Returns the AST node that a source location points to.
-///
-/// Returns a pair of Decl* and Stmt*. If no AST node is found for the source
-/// location, the pair will contain null pointers.
-///
-/// If the source location points to just a declaration, the statement part of
-/// the pair will be null, e.g.,
-/// @code
-/// int foo;
-/// @endcode
-/// If the source location points at 'foo', the pair will contain the VarDecl
-/// of foo and a null Stmt.
-///
-/// If the source location points to a statement node, the returned declaration
-/// will be the immediate 'parent' declaration of the statement node, e.g.,
-/// @code
-/// void f() {
-/// int foo = 100;
-/// ++foo;
-/// }
-/// @endcode
-/// Pointing at '100' will return a <VarDecl 'foo', IntegerLiteral '100'> pair.
-/// Pointing at '++foo' will return a <FunctionDecl 'f', UnaryOperator> pair.
-///
-std::pair<Decl *, Stmt *> ResolveLocationInAST(ASTContext &Ctx,
- SourceLocation Loc);
-
} // end namespace clang
#endif