summaryrefslogtreecommitdiffstats
path: root/include/clang/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h6
-rw-r--r--include/clang/Frontend/ASTUnit.h87
-rw-r--r--include/clang/Frontend/AnalysisConsumer.h2
-rw-r--r--include/clang/Frontend/CompilerInstance.h12
-rw-r--r--include/clang/Frontend/CompilerInvocation.h14
-rw-r--r--include/clang/Frontend/FrontendOptions.h7
-rw-r--r--include/clang/Frontend/HeaderSearchOptions.h12
-rw-r--r--include/clang/Frontend/PCHBitCodes.h4
-rw-r--r--include/clang/Frontend/PCHReader.h8
-rw-r--r--include/clang/Frontend/PCHWriter.h3
-rw-r--r--include/clang/Frontend/PreprocessorOptions.h19
11 files changed, 130 insertions, 44 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index 26efa97..20bf83e 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -94,9 +94,9 @@ ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP,
bool SyntaxHighlight = true,
bool HighlightMacros = true);
-// PCH generator: generates a precompiled header file; this file can be
-// used later with the PCHReader (clang-cc option -include-pch)
-// to speed up compile times.
+// PCH generator: generates a precompiled header file; this file can be used
+// later with the PCHReader (clang -cc1 option -include-pch) to speed up compile
+// times.
ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
llvm::raw_ostream *OS,
const char *isysroot = 0);
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index 04dc5ed..f18972a 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -16,10 +16,11 @@
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/OwningPtr.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Basic/FileManager.h"
#include "clang/Index/ASTLocation.h"
#include <string>
+#include <vector>
+#include <cassert>
namespace clang {
class ASTContext;
@@ -32,14 +33,12 @@ class HeaderSearch;
class Preprocessor;
class SourceManager;
class TargetInfo;
-class TextDiagnosticBuffer;
using namespace idx;
/// \brief Utility class for loading a ASTContext from a PCH file.
///
class ASTUnit {
- Diagnostic Diags;
FileManager FileMgr;
SourceManager SourceMgr;
@@ -48,22 +47,39 @@ class ASTUnit {
llvm::OwningPtr<Preprocessor> PP;
llvm::OwningPtr<ASTContext> Ctx;
bool tempFile;
-
+
// OnlyLocalDecls - when true, walking this AST should only visit declarations
// that come from the AST itself, not from included precompiled headers.
// FIXME: This is temporary; eventually, CIndex will always do this.
bool OnlyLocalDecls;
-
+
+ /// Track whether the main file was loaded from an AST or not.
+ bool MainFileIsAST;
+
+ /// Track the top-level decls which appeared in an ASTUnit which was loaded
+ /// from a source file.
+ //
+ // FIXME: This is just an optimization hack to avoid deserializing large parts
+ // of a PCH file when using the Index library on an ASTUnit loaded from
+ // source. In the long term we should make the Index library use efficient and
+ // more scalable search mechanisms.
+ std::vector<Decl*> TopLevelDecls;
+
+ /// The name of the original source file used to generate this ASTUnit.
+ std::string OriginalSourceFile;
+
// Critical optimization when using clang_getCursor().
ASTLocation LastLoc;
-
+
ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT
ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT
public:
- ASTUnit(DiagnosticClient *diagClient = NULL);
+ ASTUnit(bool MainFileIsAST);
~ASTUnit();
+ bool isMainFileAST() const { return MainFileIsAST; }
+
const SourceManager &getSourceManager() const { return SourceMgr; }
SourceManager &getSourceManager() { return SourceMgr; }
@@ -73,37 +89,38 @@ public:
const ASTContext &getASTContext() const { return *Ctx.get(); }
ASTContext &getASTContext() { return *Ctx.get(); }
- const Diagnostic &getDiagnostic() const { return Diags; }
- Diagnostic &getDiagnostic() { return Diags; }
-
const FileManager &getFileManager() const { return FileMgr; }
FileManager &getFileManager() { return FileMgr; }
-
+
const std::string &getOriginalSourceFileName();
const std::string &getPCHFileName();
void unlinkTemporaryFile() { tempFile = true; }
-
+
bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
-
+
void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; }
ASTLocation getLastASTLocation() const { return LastLoc; }
-
+
+ std::vector<Decl*> &getTopLevelDecls() {
+ assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
+ return TopLevelDecls;
+ }
+ const std::vector<Decl*> &getTopLevelDecls() const {
+ assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
+ return TopLevelDecls;
+ }
+
/// \brief Create a ASTUnit from a PCH file.
///
/// \param Filename - The PCH file to load.
///
- /// \param DiagClient - The diagnostics client to use. Specify NULL
- /// to use a default client that emits warnings/errors to standard error.
- /// The ASTUnit objects takes ownership of this object.
- ///
- /// \param ErrMsg - Error message to report if the PCH file could not be
- /// loaded.
+ /// \param Diags - The diagnostics engine to use for reporting errors; its
+ /// lifetime is expected to extend past that of the returned ASTUnit.
///
/// \returns - The initialized ASTUnit or null if the PCH failed to load.
static ASTUnit *LoadFromPCHFile(const std::string &Filename,
- std::string *ErrMsg = 0,
- DiagnosticClient *DiagClient = NULL,
+ Diagnostic &Diags,
bool OnlyLocalDecls = false,
bool UseBumpAllocator = false);
@@ -113,15 +130,35 @@ public:
/// \param CI - The compiler invocation to use; it must have exactly one input
/// source file.
///
- /// \param Diags - The diagnostics engine to use for reporting errors.
+ /// \param Diags - The diagnostics engine to use for reporting errors; its
+ /// lifetime is expected to extend past that of the returned ASTUnit.
//
// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
// shouldn't need to specify them at construction time.
static ASTUnit *LoadFromCompilerInvocation(const CompilerInvocation &CI,
Diagnostic &Diags,
- bool OnlyLocalDecls = false,
- bool UseBumpAllocator = false);
+ bool OnlyLocalDecls = false);
+ /// LoadFromCommandLine - Create an ASTUnit from a vector of command line
+ /// arguments, which must specify exactly one source file.
+ ///
+ /// \param ArgBegin - The beginning of the argument vector.
+ ///
+ /// \param ArgEnd - The end of the argument vector.
+ ///
+ /// \param Diags - The diagnostics engine to use for reporting errors; its
+ /// lifetime is expected to extend past that of the returned ASTUnit.
+ ///
+ /// \param ResourceFilesPath - The path to the compiler resource files.
+ //
+ // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
+ // shouldn't need to specify them at construction time.
+ static ASTUnit *LoadFromCommandLine(const char **ArgBegin,
+ const char **ArgEnd,
+ Diagnostic &Diags,
+ llvm::StringRef ResourceFilesPath,
+ bool OnlyLocalDecls = false,
+ bool UseBumpAllocator = false);
};
} // namespace clang
diff --git a/include/clang/Frontend/AnalysisConsumer.h b/include/clang/Frontend/AnalysisConsumer.h
index 24fed6e..f55e5dc 100644
--- a/include/clang/Frontend/AnalysisConsumer.h
+++ b/include/clang/Frontend/AnalysisConsumer.h
@@ -62,6 +62,7 @@ public:
std::string AnalyzeSpecificFunction;
unsigned AnalyzeAll : 1;
unsigned AnalyzerDisplayProgress : 1;
+ unsigned AnalyzeNestedBlocks : 1;
unsigned EagerlyAssume : 1;
unsigned PurgeDead : 1;
unsigned TrimGraph : 1;
@@ -76,6 +77,7 @@ public:
AnalysisDiagOpt = PD_HTML;
AnalyzeAll = 0;
AnalyzerDisplayProgress = 0;
+ AnalyzeNestedBlocks = 0;
EagerlyAssume = 0;
PurgeDead = 1;
TrimGraph = 0;
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index d7e7d99..18ec429 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -222,7 +222,7 @@ public:
void setDiagnostics(Diagnostic *Value);
DiagnosticClient &getDiagnosticClient() const {
- assert(Target && "Compiler instance has no diagnostic client!");
+ assert(DiagClient && "Compiler instance has no diagnostic client!");
return *DiagClient;
}
@@ -419,9 +419,13 @@ public:
/// logging information.
///
/// Note that this creates an unowned DiagnosticClient, if using directly the
- /// caller is responsible for releaseing the returned Diagnostic's client
+ /// caller is responsible for releasing the returned Diagnostic's client
/// eventually.
///
+ /// \param Opts - The diagnostic options; note that the created text
+ /// diagnostic object contains a reference to these options and its lifetime
+ /// must extend past that of the diagnostic engine.
+ ///
/// \return The new object on success, or null on failure.
static Diagnostic *createDiagnostics(const DiagnosticOptions &Opts,
int Argc, char **Argv);
@@ -482,12 +486,16 @@ public:
/// Create the default output file (from the invocation's options) and add it
/// to the list of tracked output files.
+ ///
+ /// \return - Null on error.
llvm::raw_fd_ostream *
createDefaultOutputFile(bool Binary = true, llvm::StringRef BaseInput = "",
llvm::StringRef Extension = "");
/// Create a new output file and add it to the list of tracked output files,
/// optionally deriving the output path name.
+ ///
+ /// \return - Null on error.
llvm::raw_fd_ostream *
createOutputFile(llvm::StringRef OutputPath, bool Binary = true,
llvm::StringRef BaseInput = "",
diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h
index e7c51aa..f5a9053 100644
--- a/include/clang/Frontend/CompilerInvocation.h
+++ b/include/clang/Frontend/CompilerInvocation.h
@@ -82,15 +82,19 @@ public:
/// \param Res [out] - The resulting invocation.
/// \param ArgBegin - The first element in the argument vector.
/// \param ArgEnd - The last element in the argument vector.
+ /// \param Diags - The diagnostic engine to use for errors.
+ static void CreateFromArgs(CompilerInvocation &Res, const char **ArgBegin,
+ const char **ArgEnd, Diagnostic &Diags);
+
+ /// GetBuiltinIncludePath - Get the directory where the compiler headers
+ /// reside, relative to the compiler binary (found by the passed in
+ /// arguments).
+ ///
/// \param Argv0 - The program path (from argv[0]), for finding the builtin
/// compiler path.
/// \param MainAddr - The address of main (or some other function in the main
/// executable), for finding the builtin compiler path.
- /// \param Diags - The diagnostic engine to use for errors.
- static void CreateFromArgs(CompilerInvocation &Res, const char **ArgBegin,
- const char **ArgEnd, const char *Argv0,
- void *MainAddr,
- Diagnostic &Diags);
+ static std::string GetResourcesPath(const char *Argv0, void *MainAddr);
/// toArgs - Convert the CompilerInvocation to a list of strings suitable for
/// passing to CreateFromArgs.
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index c1ec8e7..36fea7f 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -77,12 +77,14 @@ public:
unsigned RelocatablePCH : 1; ///< When generating PCH files,
/// instruct the PCH writer to create
/// relocatable PCH files.
+ unsigned ShowHelp : 1; ///< Show the -help text.
unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion
/// results.
unsigned ShowStats : 1; ///< Show frontend performance
/// metrics and statistics.
unsigned ShowTimers : 1; ///< Show timers for individual
/// actions.
+ unsigned ShowVersion : 1; ///< Show the -version text.
/// The input files and their types.
std::vector<std::pair<InputKind, std::string> > Inputs;
@@ -105,6 +107,9 @@ public:
/// The name of the action to run when using a plugin action.
std::string ActionName;
+ /// The list of plugins to load.
+ std::vector<std::string> Plugins;
+
public:
FrontendOptions() {
DebugCodeCompletionPrinter = 1;
@@ -113,9 +118,11 @@ public:
ProgramAction = frontend::ParseSyntaxOnly;
ActionName = "";
RelocatablePCH = 0;
+ ShowHelp = 0;
ShowMacrosInCodeCompletion = 0;
ShowStats = 0;
ShowTimers = 0;
+ ShowVersion = 0;
}
/// getInputKindForExtension - Return the appropriate input kind for a file
diff --git a/include/clang/Frontend/HeaderSearchOptions.h b/include/clang/Frontend/HeaderSearchOptions.h
index 6712977..6904085 100644
--- a/include/clang/Frontend/HeaderSearchOptions.h
+++ b/include/clang/Frontend/HeaderSearchOptions.h
@@ -61,9 +61,12 @@ public:
std::string CXXEnvIncPath;
std::string ObjCXXEnvIncPath;
- /// If non-empty, the path to the compiler builtin include directory, which
- /// will be searched following the user and environment includes.
- std::string BuiltinIncludePath;
+ /// The directory which holds the compiler resource files (builtin includes,
+ /// etc.).
+ std::string ResourceDir;
+
+ /// Include the compiler builtin includes.
+ unsigned UseBuiltinIncludes : 1;
/// Include the system standard include search directories.
unsigned UseStandardIncludes : 1;
@@ -73,7 +76,8 @@ public:
public:
HeaderSearchOptions(llvm::StringRef _Sysroot = "/")
- : Sysroot(_Sysroot), UseStandardIncludes(true), Verbose(false) {}
+ : Sysroot(_Sysroot), UseBuiltinIncludes(true),
+ UseStandardIncludes(true), Verbose(false) {}
/// AddPath - Add the \arg Path path to the specified \arg Group list.
void AddPath(llvm::StringRef Path, frontend::IncludeDirGroup Group,
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
index 98463c3..c8c49c8 100644
--- a/include/clang/Frontend/PCHBitCodes.h
+++ b/include/clang/Frontend/PCHBitCodes.h
@@ -404,7 +404,9 @@ namespace clang {
/// \brief An ElaboratedType record.
TYPE_ELABORATED = 24,
/// \brief A SubstTemplateTypeParmType record.
- TYPE_SUBST_TEMPLATE_TYPE_PARM = 25
+ TYPE_SUBST_TEMPLATE_TYPE_PARM = 25,
+ /// \brief An UnresolvedUsingType record.
+ TYPE_UNRESOLVED_USING = 26
};
/// \brief The type IDs for special types constructed by semantic
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index 85861fa..7e2c656 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -530,7 +530,8 @@ public:
/// \brief Retrieve the name of the original source file name
/// directly from the PCH file, without actually loading the PCH
/// file.
- static std::string getOriginalSourceFile(const std::string &PCHFileName);
+ static std::string getOriginalSourceFile(const std::string &PCHFileName,
+ Diagnostic &Diags);
/// \brief Returns the suggested contents of the predefines buffer,
/// which contains a (typically-empty) subset of the predefines
@@ -552,7 +553,7 @@ public:
const RecordData &Record, unsigned &Idx);
/// \brief Reads a declarator info from the given record.
- virtual DeclaratorInfo *GetDeclaratorInfo(const RecordData &Record,
+ virtual TypeSourceInfo *GetTypeSourceInfo(const RecordData &Record,
unsigned &Idx);
/// \brief Resolve a type ID into a type, potentially building a new
@@ -625,6 +626,9 @@ public:
/// tree.
virtual void InitializeSema(Sema &S);
+ /// \brief Inform the semantic consumer that Sema is no longer available.
+ virtual void ForgetSema() { SemaObj = 0; }
+
/// \brief Retrieve the IdentifierInfo for the named identifier.
///
/// This routine builds a new IdentifierInfo for the given identifier. If any
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h
index b520f4b..212130e 100644
--- a/include/clang/Frontend/PCHWriter.h
+++ b/include/clang/Frontend/PCHWriter.h
@@ -44,7 +44,6 @@ class TargetInfo;
/// 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);
}
@@ -274,7 +273,7 @@ public:
void AddTypeRef(QualType T, RecordData &Record);
/// \brief Emits a reference to a declarator info.
- void AddDeclaratorInfo(DeclaratorInfo *DInfo, RecordData &Record);
+ void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record);
/// \brief Emits a template argument location.
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
diff --git a/include/clang/Frontend/PreprocessorOptions.h b/include/clang/Frontend/PreprocessorOptions.h
index f0c1d3c..c43a1fe 100644
--- a/include/clang/Frontend/PreprocessorOptions.h
+++ b/include/clang/Frontend/PreprocessorOptions.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <string>
+#include <utility>
#include <vector>
namespace clang {
@@ -41,6 +42,21 @@ public:
/// If given, a PTH cache file to use for speeding up header parsing.
std::string TokenCache;
+ /// \brief The set of file remappings, which take existing files on
+ /// the system (the first part of each pair) and gives them the
+ /// contents of other files on the system (the second part of each
+ /// pair).
+ std::vector<std::pair<std::string, std::string> > RemappedFiles;
+
+ typedef std::vector<std::pair<std::string, std::string> >::const_iterator
+ remapped_file_iterator;
+ remapped_file_iterator remapped_file_begin() const {
+ return RemappedFiles.begin();
+ }
+ remapped_file_iterator remapped_file_end() const {
+ return RemappedFiles.end();
+ }
+
public:
PreprocessorOptions() : UsePredefines(true) {}
@@ -50,6 +66,9 @@ public:
void addMacroUndef(llvm::StringRef Name) {
Macros.push_back(std::make_pair(Name, true));
}
+ void addRemappedFile(llvm::StringRef From, llvm::StringRef To) {
+ RemappedFiles.push_back(std::make_pair(From, To));
+ }
};
} // end namespace clang
OpenPOWER on IntegriCloud