summaryrefslogtreecommitdiffstats
path: root/include/clang/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/CompilerInstance.h38
-rw-r--r--include/clang/Frontend/DiagnosticOptions.h5
-rw-r--r--include/clang/Frontend/PCHReader.h14
-rw-r--r--include/clang/Frontend/Utils.h32
4 files changed, 81 insertions, 8 deletions
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 18ec429..edafe62 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -32,6 +32,7 @@ class Diagnostic;
class DiagnosticClient;
class ExternalASTSource;
class FileManager;
+class FrontendAction;
class Preprocessor;
class Source;
class SourceManager;
@@ -103,6 +104,42 @@ public:
bool _OwnsLLVMContext = true);
~CompilerInstance();
+ /// @name High-Level Operations
+ /// {
+
+ /// ExecuteAction - Execute the provided action against the compiler's
+ /// CompilerInvocation object.
+ ///
+ /// This function makes the following assumptions:
+ ///
+ /// - The invocation options should be initialized. This function does not
+ /// handle the '-help' or '-version' options, clients should handle those
+ /// directly.
+ ///
+ /// - The diagnostics engine should have already been created by the client.
+ ///
+ /// - No other CompilerInstance state should have been initialized (this is
+ /// an unchecked error).
+ ///
+ /// - Clients should have initialized any LLVM target features that may be
+ /// required.
+ ///
+ /// - Clients should eventually call llvm_shutdown() upon the completion of
+ /// this routine to ensure that any managed objects are properly destroyed.
+ ///
+ /// Note that this routine may write output to 'stderr'.
+ ///
+ /// \param Act - The action to execute.
+ /// \return - True on success.
+ //
+ // FIXME: This function should take the stream to write any debugging /
+ // verbose output to as an argument.
+ //
+ // FIXME: Eliminate the llvm_shutdown requirement, that should either be part
+ // of the context or else not CompilerInstance specific.
+ bool ExecuteAction(FrontendAction &Act);
+
+ /// }
/// @name LLVM Context
/// {
@@ -451,6 +488,7 @@ public:
const HeaderSearchOptions &,
const DependencyOutputOptions &,
const TargetInfo &,
+ const FrontendOptions &,
SourceManager &, FileManager &);
/// Create the AST context.
diff --git a/include/clang/Frontend/DiagnosticOptions.h b/include/clang/Frontend/DiagnosticOptions.h
index 6346dc0..13039bb 100644
--- a/include/clang/Frontend/DiagnosticOptions.h
+++ b/include/clang/Frontend/DiagnosticOptions.h
@@ -35,6 +35,10 @@ public:
/// diagnostics, indicated by markers in the
/// input source file.
+ /// The distance between tab stops.
+ unsigned TabStop;
+ enum { DefaultTabStop = 8, MaxTabStop = 100 };
+
/// Column limit for formatting message diagnostics, or 0 if unused.
unsigned MessageLength;
@@ -49,6 +53,7 @@ public:
public:
DiagnosticOptions() {
IgnoreWarnings = 0;
+ TabStop = DefaultTabStop;
MessageLength = 0;
NoRewriteMacros = 0;
Pedantic = 0;
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index 7e2c656..9665ce1 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -20,6 +20,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Type.h"
#include "clang/AST/TemplateBase.h"
+#include "clang/Lex/ExternalPreprocessorSource.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
@@ -146,7 +147,8 @@ public:
/// required when traversing the AST. Only those AST nodes that are
/// actually required will be de-serialized.
class PCHReader
- : public ExternalSemaSource,
+ : public ExternalPreprocessorSource,
+ public ExternalSemaSource,
public IdentifierInfoLookup,
public ExternalIdentifierLookup,
public ExternalSLocEntrySource {
@@ -183,6 +185,10 @@ private:
llvm::BitstreamReader StreamFile;
llvm::BitstreamCursor Stream;
+ /// \brief The cursor to the start of the preprocessor block, which stores
+ /// all of the macro definitions.
+ llvm::BitstreamCursor MacroCursor;
+
/// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It
/// has read all the abbreviations at the start of the block and is ready to
/// jump around with these in context.
@@ -634,8 +640,7 @@ public:
/// This routine builds a new IdentifierInfo for the given identifier. If any
/// declarations with this name are visible from translation unit scope, their
/// declarations will be deserialized and introduced into the declaration
- /// chain of the identifier. FIXME: if this identifier names a macro,
- /// deserialize the macro.
+ /// chain of the identifier.
virtual IdentifierInfo* get(const char *NameStart, const char *NameEnd);
IdentifierInfo* get(llvm::StringRef Name) {
return get(Name.begin(), Name.end());
@@ -712,6 +717,9 @@ public:
/// \brief Reads the macro record located at the given offset.
void ReadMacroRecord(uint64_t Offset);
+ /// \brief Read the set of macros defined by this external macro source.
+ virtual void ReadDefinedMacros();
+
/// \brief Retrieve the AST context that this PCH reader
/// supplements.
ASTContext *getContext() { return Context; }
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 27c14c9..c8df494 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -15,13 +15,11 @@
#define LLVM_CLANG_FRONTEND_UTILS_H
#include "llvm/ADT/StringRef.h"
-#include <vector>
-#include <string>
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
namespace llvm {
class Triple;
-class raw_ostream;
-class raw_fd_ostream;
}
namespace clang {
@@ -41,6 +39,29 @@ class PreprocessorOutputOptions;
class SourceManager;
class Stmt;
class TargetInfo;
+class FrontendOptions;
+
+class MacroBuilder {
+ llvm::raw_ostream &Out;
+public:
+ MacroBuilder(llvm::raw_ostream &Output) : Out(Output) {}
+
+ /// Append a #define line for macro of the form "#define Name Value\n".
+ void defineMacro(const llvm::Twine &Name, const llvm::Twine &Value = "1") {
+ Out << "#define " << Name << ' ' << Value << '\n';
+ }
+
+ /// Append a #undef line for Name. Name should be of the form XXX
+ /// and we emit "#undef XXX".
+ void undefineMacro(const llvm::Twine &Name) {
+ Out << "#undef " << Name << '\n';
+ }
+
+ /// Directly append Str and a newline to the underlying buffer.
+ void append(const llvm::Twine &Str) {
+ Out << Str << '\n';
+ }
+};
/// Normalize \arg File for use in a user defined #include directive (in the
/// predefines buffer).
@@ -56,7 +77,8 @@ void ApplyHeaderSearchOptions(HeaderSearch &HS,
/// environment ready to process a single file.
void InitializePreprocessor(Preprocessor &PP,
const PreprocessorOptions &PPOpts,
- const HeaderSearchOptions &HSOpts);
+ const HeaderSearchOptions &HSOpts,
+ const FrontendOptions &FEOpts);
/// ProcessWarningOptions - Initialize the diagnostic client and process the
/// warning options specified on the command line.
OpenPOWER on IntegriCloud