diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Frontend')
32 files changed, 5230 insertions, 0 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h b/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h new file mode 100644 index 0000000..c45bd40 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h @@ -0,0 +1,64 @@ +//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// AST Consumers. +// +//===----------------------------------------------------------------------===// + +#ifndef DRIVER_ASTCONSUMERS_H +#define DRIVER_ASTCONSUMERS_H + +#include <string> + +namespace llvm { + class raw_ostream; + namespace sys { class Path; } +} +namespace clang { + +class ASTConsumer; +class CodeGenOptions; +class Diagnostic; +class FileManager; +class LangOptions; +class Preprocessor; +class TargetOptions; + +// 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); + +// 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, +// but the implementation is still incomplete. +ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS); + +// AST dumper: dumps the raw AST in human-readable form to stderr; this is +// intended for debugging. +ASTConsumer *CreateASTDumper(); + +// AST XML-dumper: dumps out the AST to stderr in a very detailed XML +// format; this is intended for particularly intense debugging. +ASTConsumer *CreateASTDumperXML(llvm::raw_ostream &OS); + +// Graphical AST viewer: for each function definition, creates a graph of +// the AST and displays it with the graph viewer "dotty". Also outputs +// function declarations to stderr. +ASTConsumer *CreateASTViewer(); + +// DeclContext printer: prints out the DeclContext tree in human-readable form +// to stderr; this is intended for debugging. +ASTConsumer *CreateDeclContextPrinter(); + +} // end clang namespace + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h new file mode 100644 index 0000000..e935633 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h @@ -0,0 +1,654 @@ +//===--- ASTUnit.h - ASTUnit utility ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// ASTUnit utility class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H +#define LLVM_CLANG_FRONTEND_ASTUNIT_H + +#include "clang/Index/ASTLocation.h" +#include "clang/Serialization/ASTBitCodes.h" +#include "clang/Sema/Sema.h" +#include "clang/Sema/CodeCompleteConsumer.h" +#include "clang/Lex/PreprocessingRecord.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang-c/Index.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/Support/Path.h" +#include <map> +#include <string> +#include <vector> +#include <cassert> +#include <utility> +#include <sys/types.h> + +namespace llvm { + class MemoryBuffer; +} + +namespace clang { +class ASTContext; +class CodeCompleteConsumer; +class CompilerInvocation; +class Decl; +class Diagnostic; +class FileEntry; +class FileManager; +class HeaderSearch; +class Preprocessor; +class SourceManager; +class TargetInfo; + +using namespace idx; + +/// \brief Allocator for a cached set of global code completions. +class GlobalCodeCompletionAllocator + : public CodeCompletionAllocator, + public llvm::RefCountedBase<GlobalCodeCompletionAllocator> +{ + +}; + +/// \brief Utility class for loading a ASTContext from an AST file. +/// +class ASTUnit { +public: + typedef std::map<FileID, std::vector<PreprocessedEntity *> > + PreprocessedEntitiesByFileMap; + +private: + llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; + llvm::OwningPtr<FileManager> FileMgr; + llvm::OwningPtr<SourceManager> SourceMgr; + llvm::OwningPtr<HeaderSearch> HeaderInfo; + llvm::OwningPtr<TargetInfo> Target; + llvm::OwningPtr<Preprocessor> PP; + llvm::OwningPtr<ASTContext> Ctx; + + FileSystemOptions FileSystemOpts; + + /// \brief The AST consumer that received information about the translation + /// unit as it was parsed or loaded. + llvm::OwningPtr<ASTConsumer> Consumer; + + /// \brief The semantic analysis object used to type-check the translation + /// unit. + llvm::OwningPtr<Sema> TheSema; + + /// Optional owned invocation, just used to make the invocation used in + /// LoadFromCommandLine available. + llvm::OwningPtr<CompilerInvocation> Invocation; + + /// \brief The set of target features. + /// + /// FIXME: each time we reparse, we need to restore the set of target + /// features from this vector, because TargetInfo::CreateTargetInfo() + /// mangles the target options in place. Yuck! + std::vector<std::string> TargetFeatures; + + // 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; + + /// \brief Whether to capture any diagnostics produced. + bool CaptureDiagnostics; + + /// \brief Track whether the main file was loaded from an AST or not. + bool MainFileIsAST; + + /// \brief Whether this AST represents a complete translation unit. + bool CompleteTranslationUnit; + + /// \brief Whether we should time each operation. + bool WantTiming; + + /// 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; + + /// \brief The list of preprocessed entities which appeared when the ASTUnit + /// was loaded. + /// + /// FIXME: This is just an optimization hack to avoid deserializing large + /// parts of a PCH file while performing a walk or search. In the long term, + /// we should provide more scalable search mechanisms. + std::vector<PreprocessedEntity *> PreprocessedEntities; + + /// The name of the original source file used to generate this ASTUnit. + std::string OriginalSourceFile; + + // Critical optimization when using clang_getCursor(). + ASTLocation LastLoc; + + /// \brief The set of diagnostics produced when creating this + /// translation unit. + llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics; + + /// \brief The number of stored diagnostics that come from the driver + /// itself. + /// + /// Diagnostics that come from the driver are retained from one parse to + /// the next. + unsigned NumStoredDiagnosticsFromDriver; + + /// \brief Temporary files that should be removed when the ASTUnit is + /// destroyed. + llvm::SmallVector<llvm::sys::Path, 4> TemporaryFiles; + + /// \brief A mapping from file IDs to the set of preprocessed entities + /// stored in that file. + /// + /// FIXME: This is just an optimization hack to avoid searching through + /// many preprocessed entities during cursor traversal in the CIndex library. + /// Ideally, we would just be able to perform a binary search within the + /// list of preprocessed entities. + PreprocessedEntitiesByFileMap PreprocessedEntitiesByFile; + + /// \brief Simple hack to allow us to assert that ASTUnit is not being + /// used concurrently, which is not supported. + /// + /// Clients should create instances of the ConcurrencyCheck class whenever + /// using the ASTUnit in a way that isn't intended to be concurrent, which is + /// just about any usage. + unsigned int ConcurrencyCheckValue; + static const unsigned int CheckLocked = 28573289; + static const unsigned int CheckUnlocked = 9803453; + + /// \brief Counter that determines when we want to try building a + /// precompiled preamble. + /// + /// If zero, we will never build a precompiled preamble. Otherwise, + /// it's treated as a counter that decrements each time we reparse + /// without the benefit of a precompiled preamble. When it hits 1, + /// we'll attempt to rebuild the precompiled header. This way, if + /// building the precompiled preamble fails, we won't try again for + /// some number of calls. + unsigned PreambleRebuildCounter; + + /// \brief The file in which the precompiled preamble is stored. + std::string PreambleFile; + + /// \brief The contents of the preamble that has been precompiled to + /// \c PreambleFile. + std::vector<char> Preamble; + + /// \brief Whether the preamble ends at the start of a new line. + /// + /// Used to inform the lexer as to whether it's starting at the beginning of + /// a line after skipping the preamble. + bool PreambleEndsAtStartOfLine; + + /// \brief The size of the source buffer that we've reserved for the main + /// file within the precompiled preamble. + unsigned PreambleReservedSize; + + /// \brief Keeps track of the files that were used when computing the + /// preamble, with both their buffer size and their modification time. + /// + /// If any of the files have changed from one compile to the next, + /// the preamble must be thrown away. + llvm::StringMap<std::pair<off_t, time_t> > FilesInPreamble; + + /// \brief When non-NULL, this is the buffer used to store the contents of + /// the main file when it has been padded for use with the precompiled + /// preamble. + llvm::MemoryBuffer *SavedMainFileBuffer; + + /// \brief When non-NULL, this is the buffer used to store the + /// contents of the preamble when it has been padded to build the + /// precompiled preamble. + llvm::MemoryBuffer *PreambleBuffer; + + /// \brief The number of warnings that occurred while parsing the preamble. + /// + /// This value will be used to restore the state of the \c Diagnostic object + /// when re-using the precompiled preamble. Note that only the + /// number of warnings matters, since we will not save the preamble + /// when any errors are present. + unsigned NumWarningsInPreamble; + + /// \brief The number of diagnostics that were stored when parsing + /// the precompiled preamble. + /// + /// This value is used to determine how many of the stored + /// diagnostics should be retained when reparsing in the presence of + /// a precompiled preamble. + unsigned NumStoredDiagnosticsInPreamble; + + /// \brief A list of the serialization ID numbers for each of the top-level + /// declarations parsed within the precompiled preamble. + std::vector<serialization::DeclID> TopLevelDeclsInPreamble; + + /// \brief A list of the offsets into the precompiled preamble which + /// correspond to preprocessed entities. + std::vector<uint64_t> PreprocessedEntitiesInPreamble; + + /// \brief Whether we should be caching code-completion results. + bool ShouldCacheCodeCompletionResults; + + static void ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags, + const char **ArgBegin, const char **ArgEnd, + ASTUnit &AST, bool CaptureDiagnostics); + +public: + /// \brief A cached code-completion result, which may be introduced in one of + /// many different contexts. + struct CachedCodeCompletionResult { + /// \brief The code-completion string corresponding to this completion + /// result. + CodeCompletionString *Completion; + + /// \brief A bitmask that indicates which code-completion contexts should + /// contain this completion result. + /// + /// The bits in the bitmask correspond to the values of + /// CodeCompleteContext::Kind. To map from a completion context kind to a + /// bit, subtract one from the completion context kind and shift 1 by that + /// number of bits. Many completions can occur in several different + /// contexts. + unsigned ShowInContexts; + + /// \brief The priority given to this code-completion result. + unsigned Priority; + + /// \brief The libclang cursor kind corresponding to this code-completion + /// result. + CXCursorKind Kind; + + /// \brief The availability of this code-completion result. + CXAvailabilityKind Availability; + + /// \brief The simplified type class for a non-macro completion result. + SimplifiedTypeClass TypeClass; + + /// \brief The type of a non-macro completion result, stored as a unique + /// integer used by the string map of cached completion types. + /// + /// This value will be zero if the type is not known, or a unique value + /// determined by the formatted type string. Se \c CachedCompletionTypes + /// for more information. + unsigned Type; + }; + + /// \brief Retrieve the mapping from formatted type names to unique type + /// identifiers. + llvm::StringMap<unsigned> &getCachedCompletionTypes() { + return CachedCompletionTypes; + } + + /// \brief Retrieve the allocator used to cache global code completions. + llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + getCachedCompletionAllocator() { + return CachedCompletionAllocator; + } + +private: + /// \brief Allocator used to store cached code completions. + llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + CachedCompletionAllocator; + + /// \brief The set of cached code-completion results. + std::vector<CachedCodeCompletionResult> CachedCompletionResults; + + /// \brief A mapping from the formatted type name to a unique number for that + /// type, which is used for type equality comparisons. + llvm::StringMap<unsigned> CachedCompletionTypes; + + /// \brief A string hash of the top-level declaration and macro definition + /// names processed the last time that we reparsed the file. + /// + /// This hash value is used to determine when we need to refresh the + /// global code-completion cache. + unsigned CompletionCacheTopLevelHashValue; + + /// \brief A string hash of the top-level declaration and macro definition + /// names processed the last time that we reparsed the precompiled preamble. + /// + /// This hash value is used to determine when we need to refresh the + /// global code-completion cache after a rebuild of the precompiled preamble. + unsigned PreambleTopLevelHashValue; + + /// \brief The current hash value for the top-level declaration and macro + /// definition names + unsigned CurrentTopLevelHashValue; + + /// \brief Bit used by CIndex to mark when a translation unit may be in an + /// inconsistent state, and is not safe to free. + unsigned UnsafeToFree : 1; + + /// \brief Cache any "global" code-completion results, so that we can avoid + /// recomputing them with each completion. + void CacheCodeCompletionResults(); + + /// \brief Clear out and deallocate + void ClearCachedCompletionResults(); + + ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT + ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT + + explicit ASTUnit(bool MainFileIsAST); + + void CleanTemporaryFiles(); + bool Parse(llvm::MemoryBuffer *OverrideMainBuffer); + + std::pair<llvm::MemoryBuffer *, std::pair<unsigned, bool> > + ComputePreamble(CompilerInvocation &Invocation, + unsigned MaxLines, bool &CreatedBuffer); + + llvm::MemoryBuffer *getMainBufferWithPrecompiledPreamble( + CompilerInvocation PreambleInvocation, + bool AllowRebuild = true, + unsigned MaxLines = 0); + void RealizeTopLevelDeclsFromPreamble(); + void RealizePreprocessedEntitiesFromPreamble(); + +public: + class ConcurrencyCheck { + volatile ASTUnit &Self; + + public: + explicit ConcurrencyCheck(ASTUnit &Self) + : Self(Self) + { + assert(Self.ConcurrencyCheckValue == CheckUnlocked && + "Concurrent access to ASTUnit!"); + Self.ConcurrencyCheckValue = CheckLocked; + } + + ~ConcurrencyCheck() { + Self.ConcurrencyCheckValue = CheckUnlocked; + } + }; + friend class ConcurrencyCheck; + + ~ASTUnit(); + + bool isMainFileAST() const { return MainFileIsAST; } + + bool isUnsafeToFree() const { return UnsafeToFree; } + void setUnsafeToFree(bool Value) { UnsafeToFree = Value; } + + const Diagnostic &getDiagnostics() const { return *Diagnostics; } + Diagnostic &getDiagnostics() { return *Diagnostics; } + + 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(); } + + bool hasSema() const { return TheSema; } + Sema &getSema() const { + assert(TheSema && "ASTUnit does not have a Sema object!"); + return *TheSema; + } + + const FileManager &getFileManager() const { return *FileMgr; } + FileManager &getFileManager() { return *FileMgr; } + + const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } + + const std::string &getOriginalSourceFileName(); + const std::string &getASTFileName(); + + /// \brief Add a temporary file that the ASTUnit depends on. + /// + /// This file will be erased when the ASTUnit is destroyed. + void addTemporaryFile(const llvm::sys::Path &TempFile) { + TemporaryFiles.push_back(TempFile); + } + + bool getOnlyLocalDecls() const { return OnlyLocalDecls; } + + /// \brief Retrieve the maximum PCH level of declarations that a + /// traversal of the translation unit should consider. + unsigned getMaxPCHLevel() const; + + void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } + ASTLocation getLastASTLocation() const { return LastLoc; } + + + llvm::StringRef getMainFileName() const; + + typedef std::vector<Decl *>::iterator top_level_iterator; + + top_level_iterator top_level_begin() { + assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); + if (!TopLevelDeclsInPreamble.empty()) + RealizeTopLevelDeclsFromPreamble(); + return TopLevelDecls.begin(); + } + + top_level_iterator top_level_end() { + assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); + if (!TopLevelDeclsInPreamble.empty()) + RealizeTopLevelDeclsFromPreamble(); + return TopLevelDecls.end(); + } + + std::size_t top_level_size() const { + assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); + return TopLevelDeclsInPreamble.size() + TopLevelDecls.size(); + } + + bool top_level_empty() const { + assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!"); + return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty(); + } + + /// \brief Add a new top-level declaration. + void addTopLevelDecl(Decl *D) { + TopLevelDecls.push_back(D); + } + + /// \brief Add a new top-level declaration, identified by its ID in + /// the precompiled preamble. + void addTopLevelDeclFromPreamble(serialization::DeclID D) { + TopLevelDeclsInPreamble.push_back(D); + } + + /// \brief Retrieve a reference to the current top-level name hash value. + /// + /// Note: This is used internally by the top-level tracking action + unsigned &getCurrentTopLevelHashValue() { return CurrentTopLevelHashValue; } + + typedef std::vector<PreprocessedEntity *>::iterator pp_entity_iterator; + + pp_entity_iterator pp_entity_begin(); + pp_entity_iterator pp_entity_end(); + + /// \brief Add a new preprocessed entity that's stored at the given offset + /// in the precompiled preamble. + void addPreprocessedEntityFromPreamble(uint64_t Offset) { + PreprocessedEntitiesInPreamble.push_back(Offset); + } + + /// \brief Retrieve the mapping from File IDs to the preprocessed entities + /// within that file. + PreprocessedEntitiesByFileMap &getPreprocessedEntitiesByFile() { + return PreprocessedEntitiesByFile; + } + + // Retrieve the diagnostics associated with this AST + typedef const StoredDiagnostic *stored_diag_iterator; + stored_diag_iterator stored_diag_begin() const { + return StoredDiagnostics.begin(); + } + stored_diag_iterator stored_diag_end() const { + return StoredDiagnostics.end(); + } + unsigned stored_diag_size() const { return StoredDiagnostics.size(); } + + llvm::SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() { + return StoredDiagnostics; + } + + typedef std::vector<CachedCodeCompletionResult>::iterator + cached_completion_iterator; + + cached_completion_iterator cached_completion_begin() { + return CachedCompletionResults.begin(); + } + + cached_completion_iterator cached_completion_end() { + return CachedCompletionResults.end(); + } + + unsigned cached_completion_size() const { + return CachedCompletionResults.size(); + } + + llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename, + std::string *ErrorStr = 0); + + /// \brief Whether this AST represents a complete translation unit. + /// + /// If false, this AST is only a partial translation unit, e.g., one + /// that might still be used as a precompiled header or preamble. + bool isCompleteTranslationUnit() const { return CompleteTranslationUnit; } + + /// \brief A mapping from a file name to the memory buffer that stores the + /// remapped contents of that file. + typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile; + + /// \brief Create a ASTUnit from an AST file. + /// + /// \param Filename - The AST file to load. + /// + /// \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 AST failed to load. + static ASTUnit *LoadFromASTFile(const std::string &Filename, + llvm::IntrusiveRefCntPtr<Diagnostic> Diags, + const FileSystemOptions &FileSystemOpts, + bool OnlyLocalDecls = false, + RemappedFile *RemappedFiles = 0, + unsigned NumRemappedFiles = 0, + bool CaptureDiagnostics = false); + +private: + /// \brief Helper function for \c LoadFromCompilerInvocation() and + /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation. + /// + /// \param PrecompilePreamble Whether to precompile the preamble of this + /// translation unit, to improve the performance of reparsing. + /// + /// \returns \c true if a catastrophic failure occurred (which means that the + /// \c ASTUnit itself is invalid), or \c false otherwise. + bool LoadFromCompilerInvocation(bool PrecompilePreamble); + +public: + + /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a + /// CompilerInvocation object. + /// + /// \param CI - The compiler invocation to use; it must have exactly one input + /// source file. The ASTUnit takes ownership of the CompilerInvocation object. + /// + /// \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(CompilerInvocation *CI, + llvm::IntrusiveRefCntPtr<Diagnostic> Diags, + bool OnlyLocalDecls = false, + bool CaptureDiagnostics = false, + bool PrecompilePreamble = false, + bool CompleteTranslationUnit = true, + bool CacheCodeCompletionResults = 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, + llvm::IntrusiveRefCntPtr<Diagnostic> Diags, + llvm::StringRef ResourceFilesPath, + bool OnlyLocalDecls = false, + bool CaptureDiagnostics = false, + RemappedFile *RemappedFiles = 0, + unsigned NumRemappedFiles = 0, + bool PrecompilePreamble = false, + bool CompleteTranslationUnit = true, + bool CacheCodeCompletionResults = false, + bool CXXPrecompilePreamble = false, + bool CXXChainedPCH = false); + + /// \brief Reparse the source files using the same command-line options that + /// were originally used to produce this translation unit. + /// + /// \returns True if a failure occurred that causes the ASTUnit not to + /// contain any translation-unit information, false otherwise. + bool Reparse(RemappedFile *RemappedFiles = 0, + unsigned NumRemappedFiles = 0); + + /// \brief Perform code completion at the given file, line, and + /// column within this translation unit. + /// + /// \param File The file in which code completion will occur. + /// + /// \param Line The line at which code completion will occur. + /// + /// \param Column The column at which code completion will occur. + /// + /// \param IncludeMacros Whether to include macros in the code-completion + /// results. + /// + /// \param IncludeCodePatterns Whether to include code patterns (such as a + /// for loop) in the code-completion results. + /// + /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and + /// OwnedBuffers parameters are all disgusting hacks. They will go away. + void CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column, + RemappedFile *RemappedFiles, unsigned NumRemappedFiles, + bool IncludeMacros, bool IncludeCodePatterns, + CodeCompleteConsumer &Consumer, + Diagnostic &Diag, LangOptions &LangOpts, + SourceManager &SourceMgr, FileManager &FileMgr, + llvm::SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics, + llvm::SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers); + + /// \brief Save this translation unit to a file with the given name. + /// + /// \returns True if an error occurred, false otherwise. + bool Save(llvm::StringRef File); +}; + +} // namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def b/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def new file mode 100644 index 0000000..75b52a8 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def @@ -0,0 +1,53 @@ +//===-- Analyses.def - Metadata about Static Analyses -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the set of static analyses used by AnalysisConsumer. +// +//===----------------------------------------------------------------------===// + +#ifndef ANALYSIS +#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE) +#endif + +ANALYSIS(WarnUninitVals, "warn-uninit-values", + "Warn about uses of uninitialized variables", Code) + +ANALYSIS(ObjCMemChecker, "analyzer-check-objc-mem", + "Run the [Core] Foundation reference count checker", Code) + +#ifndef ANALYSIS_STORE +#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) +#endif + +ANALYSIS_STORE(BasicStore, "basic", "Use basic analyzer store", CreateBasicStoreManager) +ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store", CreateRegionStoreManager) +ANALYSIS_STORE(FlatStore, "flat", "Use flat analyzer store", CreateFlatStoreManager) + +#ifndef ANALYSIS_CONSTRAINTS +#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) +#endif + +ANALYSIS_CONSTRAINTS(BasicConstraints, "basic", "Use basic constraint tracking", CreateBasicConstraintManager) +ANALYSIS_CONSTRAINTS(RangeConstraints, "range", "Use constraint tracking of concrete value ranges", CreateRangeConstraintManager) + +#ifndef ANALYSIS_DIAGNOSTICS +#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) +#endif + +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) +ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results", createTextPathDiagnosticClient, true) + +#undef ANALYSIS +#undef ANALYSIS_STORE +#undef ANALYSIS_CONSTRAINTS +#undef ANALYSIS_DIAGNOSTICS +#undef ANALYSIS_STORE + diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h new file mode 100644 index 0000000..5806928 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h @@ -0,0 +1,112 @@ +//===--- AnalyzerOptions.h - Analysis Engine Options ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This header contains the structures necessary for a front-end to specify +// various analyses. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_ANALYZEROPTIONS_H +#define LLVM_CLANG_FRONTEND_ANALYZEROPTIONS_H + +#include <string> +#include <vector> + +namespace clang { +class ASTConsumer; +class Diagnostic; +class Preprocessor; +class LangOptions; + +/// Analysis - Set of available source code analyses. +enum Analyses { +#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE) NAME, +#include "clang/Frontend/Analyses.def" +NumAnalyses +}; + +/// AnalysisStores - Set of available analysis store models. +enum AnalysisStores { +#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) NAME##Model, +#include "clang/Frontend/Analyses.def" +NumStores +}; + +/// AnalysisConstraints - Set of available constraint models. +enum AnalysisConstraints { +#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) NAME##Model, +#include "clang/Frontend/Analyses.def" +NumConstraints +}; + +/// AnalysisDiagClients - Set of available diagnostic clients for rendering +/// analysis results. +enum AnalysisDiagClients { +#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN, AUTOCREAT) PD_##NAME, +#include "clang/Frontend/Analyses.def" +NUM_ANALYSIS_DIAG_CLIENTS +}; + +class AnalyzerOptions { +public: + std::vector<Analyses> AnalysisList; + /// \brief Pair of checker name and enable/disable. + std::vector<std::pair<std::string, bool> > CheckersControlList; + AnalysisStores AnalysisStoreOpt; + AnalysisConstraints AnalysisConstraintsOpt; + AnalysisDiagClients AnalysisDiagOpt; + std::string AnalyzeSpecificFunction; + unsigned MaxNodes; + unsigned MaxLoop; + unsigned AnalyzeAll : 1; + unsigned AnalyzerDisplayProgress : 1; + unsigned AnalyzeNestedBlocks : 1; + unsigned AnalyzerStats : 1; + unsigned EagerlyAssume : 1; + unsigned BufferOverflows : 1; + unsigned PurgeDead : 1; + unsigned TrimGraph : 1; + unsigned VisualizeEGDot : 1; + unsigned VisualizeEGUbi : 1; + unsigned EnableExperimentalChecks : 1; + unsigned EnableExperimentalInternalChecks : 1; + unsigned InlineCall : 1; + unsigned UnoptimizedCFG : 1; + unsigned CFGAddImplicitDtors : 1; + unsigned CFGAddInitializers : 1; + unsigned EagerlyTrimEGraph : 1; + +public: + AnalyzerOptions() { + AnalysisStoreOpt = BasicStoreModel; + AnalysisConstraintsOpt = RangeConstraintsModel; + AnalysisDiagOpt = PD_HTML; + AnalyzeAll = 0; + AnalyzerDisplayProgress = 0; + AnalyzeNestedBlocks = 0; + AnalyzerStats = 0; + EagerlyAssume = 0; + BufferOverflows = 0; + PurgeDead = 1; + TrimGraph = 0; + VisualizeEGDot = 0; + VisualizeEGUbi = 0; + EnableExperimentalChecks = 0; + EnableExperimentalInternalChecks = 0; + InlineCall = 0; + UnoptimizedCFG = 0; + CFGAddImplicitDtors = 0; + CFGAddInitializers = 0; + EagerlyTrimEGraph = 0; + } +}; + +} + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticClient.h b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticClient.h new file mode 100644 index 0000000..2d5e128 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticClient.h @@ -0,0 +1,58 @@ +//===--- ChainedDiagnosticClient.h - Chain Diagnostic Clients ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H +#define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H + +#include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/OwningPtr.h" + +namespace clang { +class LangOptions; + +/// ChainedDiagnosticClient - Chain two diagnostic clients so that diagnostics +/// go to the first client and then the second. The first diagnostic client +/// should be the "primary" client, and will be used for computing whether the +/// diagnostics should be included in counts. +class ChainedDiagnosticClient : public DiagnosticClient { + llvm::OwningPtr<DiagnosticClient> Primary; + llvm::OwningPtr<DiagnosticClient> Secondary; + +public: + ChainedDiagnosticClient(DiagnosticClient *_Primary, + DiagnosticClient *_Secondary) { + Primary.reset(_Primary); + Secondary.reset(_Secondary); + } + + virtual void BeginSourceFile(const LangOptions &LO, + const Preprocessor *PP) { + Primary->BeginSourceFile(LO, PP); + Secondary->BeginSourceFile(LO, PP); + } + + virtual void EndSourceFile() { + Secondary->EndSourceFile(); + Primary->EndSourceFile(); + } + + virtual bool IncludeInDiagnosticCounts() const { + return Primary->IncludeInDiagnosticCounts(); + } + + virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, + const DiagnosticInfo &Info) { + Primary->HandleDiagnostic(DiagLevel, Info); + Secondary->HandleDiagnostic(DiagLevel, Info); + } +}; + +} // end namspace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h new file mode 100644 index 0000000..ee85b655 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h @@ -0,0 +1,170 @@ +//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the CodeGenOptions interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H +#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H + +#include <string> + +namespace clang { + +/// CodeGenOptions - Track various options which control how the code +/// is optimized and passed to the backend. +class CodeGenOptions { +public: + enum InliningMethod { + NoInlining, // Perform no inlining whatsoever. + NormalInlining, // Use the standard function inlining pass. + OnlyAlwaysInlining // Only run the always inlining pass. + }; + + enum ObjCDispatchMethodKind { + Legacy = 0, + NonLegacy = 1, + Mixed = 2 + }; + + unsigned AsmVerbose : 1; /// -dA, -fverbose-asm. + unsigned CXAAtExit : 1; /// Use __cxa_atexit for calling destructors. + unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker + /// aliases to base ctors when possible. + unsigned DataSections : 1; /// Set when -fdata-sections is enabled + unsigned DebugInfo : 1; /// Should generate debug info (-g). + unsigned LimitDebugInfo : 1; /// Limit generated debug info to reduce size. + unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled. + unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in + /// getting .bc files that correspond to the + /// internal state before optimizations are + /// done. + unsigned DisableRedZone : 1; /// Set when -mno-red-zone is enabled. + unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what + /// Decl* various IR entities came from. Only + /// useful when running CodeGen as a + /// subroutine. + unsigned FunctionSections : 1; /// Set when -ffunction-sections is enabled + unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for + /// template classes with hidden visibility + unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with + /// hidden visibility. + unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is + /// enabled. + unsigned InstrumentForProfiling : 1; /// Set when -pg is enabled + unsigned LessPreciseFPMAD : 1; /// Enable less precise MAD instructions to be + /// generated. + unsigned MergeAllConstants : 1; /// Merge identical constants. + unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled. + unsigned NoImplicitFloat : 1; /// Set when -mno-implicit-float is enabled. + unsigned NoInfsFPMath : 1; /// Assume FP arguments, results not +-Inf. + unsigned NoNaNsFPMath : 1; /// Assume FP arguments, results not NaN. + unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss + unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use. + unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is + /// enabled. + unsigned OptimizationLevel : 3; /// The -O[0-4] option specified. + unsigned OptimizeSize : 1; /// If -Os is specified. + unsigned RelaxAll : 1; /// Relax all machine code instructions. + unsigned RelaxedAliasing : 1; /// Set when -fno-strict-aliasing is enabled. + unsigned SimplifyLibCalls : 1; /// Set when -fbuiltin is enabled. + unsigned SoftFloat : 1; /// -soft-float. + unsigned TimePasses : 1; /// Set when -ftime-report is enabled. + unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization + /// selection. + unsigned UnrollLoops : 1; /// Control whether loops are unrolled. + unsigned UnsafeFPMath : 1; /// Allow unsafe floating point optzns. + unsigned UnwindTables : 1; /// Emit unwind tables. + unsigned VerifyModule : 1; /// Control whether the module should be run + /// through the LLVM Verifier. + + /// The code model to use (-mcmodel). + std::string CodeModel; + + /// Enable additional debugging information. + std::string DebugPass; + + /// The string to embed in the debug information for the compile unit, if + /// non-empty. + std::string DwarfDebugFlags; + + /// The ABI to use for passing floating point arguments. + std::string FloatABI; + + /// The float precision limit to use, if non-empty. + std::string LimitFloatPrecision; + + /// The kind of inlining to perform. + InliningMethod Inlining; + + /// The user provided name for the "main file", if non-empty. This is useful + /// in situations where the input file name does not match the original input + /// file, for example with -save-temps. + std::string MainFileName; + + /// The name of the relocation model to use. + std::string RelocationModel; + + /// The user specified number of registers to be used for integral arguments, + /// or 0 if unspecified. + unsigned NumRegisterParameters; + +public: + CodeGenOptions() { + AsmVerbose = 0; + CXAAtExit = 1; + CXXCtorDtorAliases = 0; + DataSections = 0; + DebugInfo = 0; + LimitDebugInfo = 0; + DisableFPElim = 0; + DisableLLVMOpts = 0; + DisableRedZone = 0; + EmitDeclMetadata = 0; + FunctionSections = 0; + HiddenWeakTemplateVTables = 0; + HiddenWeakVTables = 0; + InstrumentFunctions = 0; + InstrumentForProfiling = 0; + LessPreciseFPMAD = 0; + MergeAllConstants = 1; + NoCommon = 0; + NoImplicitFloat = 0; + NoInfsFPMath = 0; + NoNaNsFPMath = 0; + NoZeroInitializedInBSS = 0; + NumRegisterParameters = 0; + ObjCDispatchMethod = Legacy; + OmitLeafFramePointer = 0; + OptimizationLevel = 0; + OptimizeSize = 0; + RelaxAll = 0; + RelaxedAliasing = 0; + SimplifyLibCalls = 1; + SoftFloat = 0; + TimePasses = 0; + UnitAtATime = 1; + UnrollLoops = 0; + UnsafeFPMath = 0; + UnwindTables = 0; + VerifyModule = 1; + + Inlining = NoInlining; + RelocationModel = "pic"; + } + + ObjCDispatchMethodKind getObjCDispatchMethod() const { + return ObjCDispatchMethodKind(ObjCDispatchMethod); + } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h b/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h new file mode 100644 index 0000000..8911cfa --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h @@ -0,0 +1,86 @@ + +//===--- CommandLineSourceLoc.h - Parsing for source locations-*- C++ -*---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Command line parsing for source locations. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_COMMANDLINESOURCELOC_H +#define LLVM_CLANG_FRONTEND_COMMANDLINESOURCELOC_H + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" + +namespace clang { + +/// \brief A source location that has been parsed on the command line. +struct ParsedSourceLocation { + std::string FileName; + unsigned Line; + unsigned Column; + +public: + /// Construct a parsed source location from a string; the Filename is empty on + /// error. + static ParsedSourceLocation FromString(llvm::StringRef Str) { + ParsedSourceLocation PSL; + std::pair<llvm::StringRef, llvm::StringRef> ColSplit = Str.rsplit(':'); + std::pair<llvm::StringRef, llvm::StringRef> LineSplit = + ColSplit.first.rsplit(':'); + + // If both tail splits were valid integers, return success. + if (!ColSplit.second.getAsInteger(10, PSL.Column) && + !LineSplit.second.getAsInteger(10, PSL.Line)) { + PSL.FileName = LineSplit.first; + + // On the command-line, stdin may be specified via "-". Inside the + // compiler, stdin is called "<stdin>". + if (PSL.FileName == "-") + PSL.FileName = "<stdin>"; + } + + return PSL; + } +}; + +} + +namespace llvm { + namespace cl { + /// \brief Command-line option parser that parses source locations. + /// + /// Source locations are of the form filename:line:column. + template<> + class parser<clang::ParsedSourceLocation> + : public basic_parser<clang::ParsedSourceLocation> { + public: + inline bool parse(Option &O, StringRef ArgName, StringRef ArgValue, + clang::ParsedSourceLocation &Val); + }; + + bool + parser<clang::ParsedSourceLocation>:: + parse(Option &O, StringRef ArgName, StringRef ArgValue, + clang::ParsedSourceLocation &Val) { + using namespace clang; + + Val = ParsedSourceLocation::FromString(ArgValue); + if (Val.FileName.empty()) { + errs() << "error: " + << "source location must be of the form filename:line:column\n"; + return true; + } + + return false; + } + } +} + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h new file mode 100644 index 0000000..7ea79e5 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h @@ -0,0 +1,625 @@ +//===-- CompilerInstance.h - Clang Compiler Instance ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ +#define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ + +#include "clang/Frontend/CompilerInvocation.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/OwningPtr.h" +#include <cassert> +#include <list> +#include <string> + +namespace llvm { +class raw_ostream; +class raw_fd_ostream; +class Timer; +} + +namespace clang { +class ASTContext; +class ASTConsumer; +class CodeCompleteConsumer; +class Diagnostic; +class DiagnosticClient; +class ExternalASTSource; +class FileManager; +class FrontendAction; +class ASTReader; +class Preprocessor; +class Sema; +class SourceManager; +class TargetInfo; + +/// CompilerInstance - Helper class for managing a single instance of the Clang +/// compiler. +/// +/// The CompilerInstance serves two purposes: +/// (1) It manages the various objects which are necessary to run the compiler, +/// for example the preprocessor, the target information, and the AST +/// context. +/// (2) It provides utility routines for constructing and manipulating the +/// common Clang objects. +/// +/// The compiler instance generally owns the instance of all the objects that it +/// manages. However, clients can still share objects by manually setting the +/// object and retaking ownership prior to destroying the CompilerInstance. +/// +/// The compiler instance is intended to simplify clients, but not to lock them +/// in to the compiler instance for everything. When possible, utility functions +/// come in two forms; a short form that reuses the CompilerInstance objects, +/// and a long form that takes explicit instances of any required objects. +class CompilerInstance { + /// The options used in this compiler instance. + llvm::OwningPtr<CompilerInvocation> Invocation; + + /// The diagnostics engine instance. + llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; + + /// The target being compiled for. + llvm::OwningPtr<TargetInfo> Target; + + /// The file manager. + llvm::OwningPtr<FileManager> FileMgr; + + /// The source manager. + llvm::OwningPtr<SourceManager> SourceMgr; + + /// The preprocessor. + llvm::OwningPtr<Preprocessor> PP; + + /// The AST context. + llvm::OwningPtr<ASTContext> Context; + + /// The AST consumer. + llvm::OwningPtr<ASTConsumer> Consumer; + + /// The code completion consumer. + llvm::OwningPtr<CodeCompleteConsumer> CompletionConsumer; + + /// \brief The semantic analysis object. + llvm::OwningPtr<Sema> TheSema; + + /// The frontend timer + llvm::OwningPtr<llvm::Timer> FrontendTimer; + + /// \brief Holds information about the output file. + /// + /// If TempFilename is not empty we must rename it to Filename at the end. + /// TempFilename may be empty and Filename non empty if creating the temporary + /// failed. + struct OutputFile { + std::string Filename; + std::string TempFilename; + llvm::raw_ostream *OS; + + OutputFile(const std::string &filename, const std::string &tempFilename, + llvm::raw_ostream *os) + : Filename(filename), TempFilename(tempFilename), OS(os) { } + }; + + /// The list of active output files. + std::list<OutputFile> OutputFiles; + + void operator=(const CompilerInstance &); // DO NOT IMPLEMENT + CompilerInstance(const CompilerInstance&); // DO NOT IMPLEMENT +public: + CompilerInstance(); + ~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 Compiler Invocation and Options + /// { + + bool hasInvocation() const { return Invocation != 0; } + + CompilerInvocation &getInvocation() { + assert(Invocation && "Compiler instance has no invocation!"); + return *Invocation; + } + + CompilerInvocation *takeInvocation() { return Invocation.take(); } + + /// setInvocation - Replace the current invocation; the compiler instance + /// takes ownership of \arg Value. + void setInvocation(CompilerInvocation *Value); + + /// } + /// @name Forwarding Methods + /// { + + AnalyzerOptions &getAnalyzerOpts() { + return Invocation->getAnalyzerOpts(); + } + const AnalyzerOptions &getAnalyzerOpts() const { + return Invocation->getAnalyzerOpts(); + } + + CodeGenOptions &getCodeGenOpts() { + return Invocation->getCodeGenOpts(); + } + const CodeGenOptions &getCodeGenOpts() const { + return Invocation->getCodeGenOpts(); + } + + DependencyOutputOptions &getDependencyOutputOpts() { + return Invocation->getDependencyOutputOpts(); + } + const DependencyOutputOptions &getDependencyOutputOpts() const { + return Invocation->getDependencyOutputOpts(); + } + + DiagnosticOptions &getDiagnosticOpts() { + return Invocation->getDiagnosticOpts(); + } + const DiagnosticOptions &getDiagnosticOpts() const { + return Invocation->getDiagnosticOpts(); + } + + const FileSystemOptions &getFileSystemOpts() const { + return Invocation->getFileSystemOpts(); + } + + FrontendOptions &getFrontendOpts() { + return Invocation->getFrontendOpts(); + } + const FrontendOptions &getFrontendOpts() const { + return Invocation->getFrontendOpts(); + } + + HeaderSearchOptions &getHeaderSearchOpts() { + return Invocation->getHeaderSearchOpts(); + } + const HeaderSearchOptions &getHeaderSearchOpts() const { + return Invocation->getHeaderSearchOpts(); + } + + LangOptions &getLangOpts() { + return Invocation->getLangOpts(); + } + const LangOptions &getLangOpts() const { + return Invocation->getLangOpts(); + } + + PreprocessorOptions &getPreprocessorOpts() { + return Invocation->getPreprocessorOpts(); + } + const PreprocessorOptions &getPreprocessorOpts() const { + return Invocation->getPreprocessorOpts(); + } + + PreprocessorOutputOptions &getPreprocessorOutputOpts() { + return Invocation->getPreprocessorOutputOpts(); + } + const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { + return Invocation->getPreprocessorOutputOpts(); + } + + TargetOptions &getTargetOpts() { + return Invocation->getTargetOpts(); + } + const TargetOptions &getTargetOpts() const { + return Invocation->getTargetOpts(); + } + + /// } + /// @name Diagnostics Engine + /// { + + bool hasDiagnostics() const { return Diagnostics != 0; } + + Diagnostic &getDiagnostics() const { + assert(Diagnostics && "Compiler instance has no diagnostics!"); + return *Diagnostics; + } + + /// setDiagnostics - Replace the current diagnostics engine; the compiler + /// instance takes ownership of \arg Value. + void setDiagnostics(Diagnostic *Value); + + DiagnosticClient &getDiagnosticClient() const { + assert(Diagnostics && Diagnostics->getClient() && + "Compiler instance has no diagnostic client!"); + return *Diagnostics->getClient(); + } + + /// } + /// @name Target Info + /// { + + bool hasTarget() const { return Target != 0; } + + TargetInfo &getTarget() const { + assert(Target && "Compiler instance has no target!"); + return *Target; + } + + /// takeTarget - Remove the current diagnostics engine and give ownership + /// to the caller. + TargetInfo *takeTarget() { return Target.take(); } + + /// setTarget - Replace the current diagnostics engine; the compiler + /// instance takes ownership of \arg Value. + void setTarget(TargetInfo *Value); + + /// } + /// @name File Manager + /// { + + bool hasFileManager() const { return FileMgr != 0; } + + FileManager &getFileManager() const { + assert(FileMgr && "Compiler instance has no file manager!"); + return *FileMgr; + } + + /// takeFileManager - Remove the current file manager and give ownership to + /// the caller. + FileManager *takeFileManager() { return FileMgr.take(); } + + /// setFileManager - Replace the current file manager; the compiler instance + /// takes ownership of \arg Value. + void setFileManager(FileManager *Value); + + /// } + /// @name Source Manager + /// { + + bool hasSourceManager() const { return SourceMgr != 0; } + + SourceManager &getSourceManager() const { + assert(SourceMgr && "Compiler instance has no source manager!"); + return *SourceMgr; + } + + /// takeSourceManager - Remove the current source manager and give ownership + /// to the caller. + SourceManager *takeSourceManager() { return SourceMgr.take(); } + + /// setSourceManager - Replace the current source manager; the compiler + /// instance takes ownership of \arg Value. + void setSourceManager(SourceManager *Value); + + /// } + /// @name Preprocessor + /// { + + bool hasPreprocessor() const { return PP != 0; } + + Preprocessor &getPreprocessor() const { + assert(PP && "Compiler instance has no preprocessor!"); + return *PP; + } + + /// takePreprocessor - Remove the current preprocessor and give ownership to + /// the caller. + Preprocessor *takePreprocessor() { return PP.take(); } + + /// setPreprocessor - Replace the current preprocessor; the compiler instance + /// takes ownership of \arg Value. + void setPreprocessor(Preprocessor *Value); + + /// } + /// @name ASTContext + /// { + + bool hasASTContext() const { return Context != 0; } + + ASTContext &getASTContext() const { + assert(Context && "Compiler instance has no AST context!"); + return *Context; + } + + /// takeASTContext - Remove the current AST context and give ownership to the + /// caller. + ASTContext *takeASTContext() { return Context.take(); } + + /// setASTContext - Replace the current AST context; the compiler instance + /// takes ownership of \arg Value. + void setASTContext(ASTContext *Value); + + /// \brief Replace the current Sema; the compiler instance takes ownership + /// of S. + void setSema(Sema *S); + + /// } + /// @name ASTConsumer + /// { + + bool hasASTConsumer() const { return Consumer != 0; } + + ASTConsumer &getASTConsumer() const { + assert(Consumer && "Compiler instance has no AST consumer!"); + return *Consumer; + } + + /// takeASTConsumer - Remove the current AST consumer and give ownership to + /// the caller. + ASTConsumer *takeASTConsumer() { return Consumer.take(); } + + /// setASTConsumer - Replace the current AST consumer; the compiler instance + /// takes ownership of \arg Value. + void setASTConsumer(ASTConsumer *Value); + + /// } + /// @name Semantic analysis + /// { + bool hasSema() const { return TheSema != 0; } + + Sema &getSema() const { + assert(TheSema && "Compiler instance has no Sema object!"); + return *TheSema; + } + + Sema *takeSema() { return TheSema.take(); } + + /// } + /// @name Code Completion + /// { + + bool hasCodeCompletionConsumer() const { return CompletionConsumer != 0; } + + CodeCompleteConsumer &getCodeCompletionConsumer() const { + assert(CompletionConsumer && + "Compiler instance has no code completion consumer!"); + return *CompletionConsumer; + } + + /// takeCodeCompletionConsumer - Remove the current code completion consumer + /// and give ownership to the caller. + CodeCompleteConsumer *takeCodeCompletionConsumer() { + return CompletionConsumer.take(); + } + + /// setCodeCompletionConsumer - Replace the current code completion consumer; + /// the compiler instance takes ownership of \arg Value. + void setCodeCompletionConsumer(CodeCompleteConsumer *Value); + + /// } + /// @name Frontend timer + /// { + + bool hasFrontendTimer() const { return FrontendTimer != 0; } + + llvm::Timer &getFrontendTimer() const { + assert(FrontendTimer && "Compiler instance has no frontend timer!"); + return *FrontendTimer; + } + + /// } + /// @name Output Files + /// { + + /// addOutputFile - Add an output file onto the list of tracked output files. + /// + /// \param OutFile - The output file info. + void addOutputFile(const OutputFile &OutFile); + + /// clearOutputFiles - Clear the output file list, destroying the contained + /// output streams. + /// + /// \param EraseFiles - If true, attempt to erase the files from disk. + void clearOutputFiles(bool EraseFiles); + + /// } + /// @name Construction Utility Methods + /// { + + /// Create the diagnostics engine using the invocation's diagnostic options + /// and replace any existing one with it. + /// + /// Note that this routine also replaces the diagnostic client, + /// allocating one if one is not provided. + /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the Diagnostic inside this AST + /// unit. + void createDiagnostics(int Argc, const char* const *Argv, + DiagnosticClient *Client = 0); + + /// Create a Diagnostic object with a the TextDiagnosticPrinter. + /// + /// The \arg Argc and \arg Argv arguments are used only for logging purposes, + /// when the diagnostic options indicate that the compiler should output + /// logging information. + /// + /// If no diagnostic client is provided, this creates a + /// DiagnosticClient that is owned by the returned diagnostic + /// object, if using directly the 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. + /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the returned Diagnostic + /// object. + /// + /// \return The new object on success, or null on failure. + static llvm::IntrusiveRefCntPtr<Diagnostic> + createDiagnostics(const DiagnosticOptions &Opts, int Argc, + const char* const *Argv, + DiagnosticClient *Client = 0); + + /// Create the file manager and replace any existing one with it. + void createFileManager(); + + /// Create the source manager and replace any existing one with it. + void createSourceManager(FileManager &FileMgr); + + /// Create the preprocessor, using the invocation, file, and source managers, + /// and replace any existing one with it. + void createPreprocessor(); + + /// Create a Preprocessor object. + /// + /// Note that this also creates a new HeaderSearch object which will be owned + /// by the resulting Preprocessor. + /// + /// \return The new object on success, or null on failure. + static Preprocessor *createPreprocessor(Diagnostic &, const LangOptions &, + const PreprocessorOptions &, + const HeaderSearchOptions &, + const DependencyOutputOptions &, + const TargetInfo &, + const FrontendOptions &, + SourceManager &, FileManager &); + + /// Create the AST context. + void createASTContext(); + + /// Create an external AST source to read a PCH file and attach it to the AST + /// context. + void createPCHExternalASTSource(llvm::StringRef Path, + bool DisablePCHValidation, + bool DisableStatCache, + void *DeserializationListener); + + /// Create an external AST source to read a PCH file. + /// + /// \return - The new object on success, or null on failure. + static ExternalASTSource * + createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot, + bool DisablePCHValidation, + bool DisableStatCache, + Preprocessor &PP, ASTContext &Context, + void *DeserializationListener, bool Preamble); + + /// Create a code completion consumer using the invocation; note that this + /// will cause the source manager to truncate the input source file at the + /// completion point. + void createCodeCompletionConsumer(); + + /// Create a code completion consumer to print code completion results, at + /// \arg Filename, \arg Line, and \arg Column, to the given output stream \arg + /// OS. + static CodeCompleteConsumer * + createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename, + unsigned Line, unsigned Column, + bool ShowMacros, + bool ShowCodePatterns, bool ShowGlobals, + llvm::raw_ostream &OS); + + /// \brief Create the Sema object to be used for parsing. + void createSema(bool CompleteTranslationUnit, + CodeCompleteConsumer *CompletionConsumer); + + /// Create the frontend timer and replace any existing one with it. + void createFrontendTimer(); + + /// 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, bool RemoveFileOnSignal = true, + llvm::StringRef BaseInput = "", + llvm::StringRef Extension = ""); + + /// Create a new output file, optionally deriving the output path name. + /// + /// If \arg OutputPath is empty, then createOutputFile will derive an output + /// path location as \arg BaseInput, with any suffix removed, and \arg + /// Extension appended. If OutputPath is not stdout createOutputFile will + /// create a new temporary file that must be renamed to OutputPath in the end. + /// + /// \param OutputPath - If given, the path to the output file. + /// \param Error [out] - On failure, the error message. + /// \param BaseInput - If \arg OutputPath is empty, the input path name to use + /// for deriving the output path. + /// \param Extension - The extension to use for derived output names. + /// \param Binary - The mode to open the file in. + /// \param RemoveFileOnSignal - Whether the file should be registered with + /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for + /// multithreaded use, as the underlying signal mechanism is not reentrant + /// \param ResultPathName [out] - If given, the result path name will be + /// stored here on success. + /// \param TempPathName [out] - If given, the temporary file path name + /// will be stored here on success. + static llvm::raw_fd_ostream * + createOutputFile(llvm::StringRef OutputPath, std::string &Error, + bool Binary = true, bool RemoveFileOnSignal = true, + llvm::StringRef BaseInput = "", + llvm::StringRef Extension = "", + std::string *ResultPathName = 0, + std::string *TempPathName = 0); + + /// } + /// @name Initialization Utility Methods + /// { + + /// InitializeSourceManager - Initialize the source manager to set InputFile + /// as the main file. + /// + /// \return True on success. + bool InitializeSourceManager(llvm::StringRef InputFile); + + /// InitializeSourceManager - Initialize the source manager to set InputFile + /// as the main file. + /// + /// \return True on success. + static bool InitializeSourceManager(llvm::StringRef InputFile, + Diagnostic &Diags, + FileManager &FileMgr, + SourceManager &SourceMgr, + const FrontendOptions &Opts); + + /// } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h new file mode 100644 index 0000000..e0329db --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h @@ -0,0 +1,193 @@ +//===-- CompilerInvocation.h - Compiler Invocation Helper Data --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_ +#define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_ + +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/TargetOptions.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Frontend/AnalyzerOptions.h" +#include "clang/Frontend/CodeGenOptions.h" +#include "clang/Frontend/DependencyOutputOptions.h" +#include "clang/Frontend/DiagnosticOptions.h" +#include "clang/Frontend/FrontendOptions.h" +#include "clang/Frontend/HeaderSearchOptions.h" +#include "clang/Frontend/LangStandard.h" +#include "clang/Frontend/PreprocessorOptions.h" +#include "clang/Frontend/PreprocessorOutputOptions.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringMap.h" +#include <string> +#include <vector> + +namespace llvm { + template<typename T> class SmallVectorImpl; +} + +namespace clang { + +class Diagnostic; + +/// CompilerInvocation - Helper class for holding the data necessary to invoke +/// the compiler. +/// +/// This class is designed to represent an abstract "invocation" of the +/// compiler, including data such as the include paths, the code generation +/// options, the warning flags, and so on. +class CompilerInvocation { + /// Options controlling the static analyzer. + AnalyzerOptions AnalyzerOpts; + + /// Options controlling IRgen and the backend. + CodeGenOptions CodeGenOpts; + + /// Options controlling dependency output. + DependencyOutputOptions DependencyOutputOpts; + + /// Options controlling the diagnostic engine. + DiagnosticOptions DiagnosticOpts; + + /// Options controlling file system operations. + FileSystemOptions FileSystemOpts; + + /// Options controlling the frontend itself. + FrontendOptions FrontendOpts; + + /// Options controlling the #include directive. + HeaderSearchOptions HeaderSearchOpts; + + /// Options controlling the language variant. + LangOptions LangOpts; + + /// Options controlling the preprocessor (aside from #include handling). + PreprocessorOptions PreprocessorOpts; + + /// Options controlling preprocessed output. + PreprocessorOutputOptions PreprocessorOutputOpts; + + /// Options controlling the target. + TargetOptions TargetOpts; + +public: + CompilerInvocation() {} + + /// @name Utility Methods + /// @{ + + /// CreateFromArgs - Create a compiler invocation from a list of input + /// options. + /// + /// \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* const *ArgBegin, + const char* const *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. + static std::string GetResourcesPath(const char *Argv0, void *MainAddr); + + /// toArgs - Convert the CompilerInvocation to a list of strings suitable for + /// passing to CreateFromArgs. + void toArgs(std::vector<std::string> &Res); + + /// setLangDefaults - Set language defaults for the given input language and + /// language standard in this CompilerInvocation. + /// + /// \param IK - The input language. + /// \param LangStd - The input language standard. + void setLangDefaults(InputKind IK, + LangStandard::Kind LangStd = LangStandard::lang_unspecified) { + setLangDefaults(LangOpts, IK, LangStd); + } + + /// setLangDefaults - Set language defaults for the given input language and + /// language standard in the given LangOptions object. + /// + /// \param LangOpts - The LangOptions object to set up. + /// \param IK - The input language. + /// \param LangStd - The input language standard. + static void setLangDefaults(LangOptions &Opts, InputKind IK, + LangStandard::Kind LangStd = LangStandard::lang_unspecified); + + /// @} + /// @name Option Subgroups + /// @{ + + AnalyzerOptions &getAnalyzerOpts() { return AnalyzerOpts; } + const AnalyzerOptions &getAnalyzerOpts() const { + return AnalyzerOpts; + } + + CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; } + const CodeGenOptions &getCodeGenOpts() const { + return CodeGenOpts; + } + + DependencyOutputOptions &getDependencyOutputOpts() { + return DependencyOutputOpts; + } + const DependencyOutputOptions &getDependencyOutputOpts() const { + return DependencyOutputOpts; + } + + DiagnosticOptions &getDiagnosticOpts() { return DiagnosticOpts; } + const DiagnosticOptions &getDiagnosticOpts() const { return DiagnosticOpts; } + + FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } + const FileSystemOptions &getFileSystemOpts() const { + return FileSystemOpts; + } + + HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; } + const HeaderSearchOptions &getHeaderSearchOpts() const { + return HeaderSearchOpts; + } + + FrontendOptions &getFrontendOpts() { return FrontendOpts; } + const FrontendOptions &getFrontendOpts() const { + return FrontendOpts; + } + + LangOptions &getLangOpts() { return LangOpts; } + const LangOptions &getLangOpts() const { return LangOpts; } + + PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; } + const PreprocessorOptions &getPreprocessorOpts() const { + return PreprocessorOpts; + } + + PreprocessorOutputOptions &getPreprocessorOutputOpts() { + return PreprocessorOutputOpts; + } + const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { + return PreprocessorOutputOpts; + } + + TargetOptions &getTargetOpts() { return TargetOpts; } + const TargetOptions &getTargetOpts() const { + return TargetOpts; + } + + /// @} +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DeclContextXML.def b/contrib/llvm/tools/clang/include/clang/Frontend/DeclContextXML.def new file mode 100644 index 0000000..39ed5f9 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DeclContextXML.def @@ -0,0 +1,113 @@ +//===-- DeclContextXML.def - Metadata about Context XML nodes ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the XML context info database as written in the +// <ReferenceSection>/<Contexts> sub-nodes of the XML document. Type nodes +// are referred by "context" reference attributes throughout the document. +// A context node never contains sub-nodes. +// The semantics of the attributes and enums are mostly self-documenting +// by looking at the appropriate internally used functions and values. +// The following macros are used: +// +// NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete +// context of class CLASS where CLASS is a class name used internally by clang. +// After a NODE_XML the definition of all (optional) attributes of that context +// node and possible sub-nodes follows. +// +// END_NODE_XML - Closes the attribute definition of the current node. +// +// ID_ATTRIBUTE_XML - Context nodes have an "id" attribute containing a +// string, which value uniquely identify that statement. Other nodes may refer +// by "context" attributes to this value. +// +// TYPE_ATTRIBUTE_XML( FN ) - Context nodes may refer to the ids of type +// nodes by a "type" attribute, if they create a type during declaration. +// For instance 'struct S;' creates both a context 'S::' and a type 'S'. +// Contexts and types always have different ids, however declarations and +// contexts may share the same ids. FN is internally used by clang. +// +// ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally +// used by clang. A boolean attribute have the values "0" or "1". +// +// ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value +// is an enumeration defined with ENUM_XML macros immediately following after +// that macro. An optional attribute is ommited, if the particular enum is the +// empty string. FN is internally used by clang. +// +// ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is +// internally used by clang. +// +// END_ENUM_XML - Closes the enumeration definition of the current attribute. +// +//===----------------------------------------------------------------------===// + +#ifndef TYPE_ATTRIBUTE_XML +# define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type") +#endif + +#ifndef CONTEXT_ATTRIBUTE_XML +# define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context") +#endif + +NODE_XML(TranslationUnitDecl, "TranslationUnit") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(FunctionDecl, "Function") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()->getAsFunctionType()) +END_NODE_XML + +NODE_XML(NamespaceDecl, "Namespace") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") +END_NODE_XML + +NODE_XML(RecordDecl, "Record") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getTypeForDecl()) +END_NODE_XML + +NODE_XML(EnumDecl, "Enum") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getTypeForDecl()) +END_NODE_XML + +NODE_XML(LinkageSpecDecl, "LinkageSpec") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_ENUM_OPT_XML(getLanguage(), "lang") + ENUM_XML(LinkageSpecDecl::lang_c, "C") + ENUM_XML(LinkageSpecDecl::lang_cxx, "CXX") + END_ENUM_XML +END_NODE_XML + +//===----------------------------------------------------------------------===// +#undef NODE_XML +#undef ID_ATTRIBUTE_XML +#undef TYPE_ATTRIBUTE_XML +#undef ATTRIBUTE_XML +#undef ATTRIBUTE_SPECIAL_XML +#undef ATTRIBUTE_OPT_XML +#undef ATTRIBUTE_ENUM_XML +#undef ATTRIBUTE_ENUM_OPT_XML +#undef ATTRIBUTE_FILE_LOCATION_XML +#undef ENUM_XML +#undef END_ENUM_XML +#undef END_NODE_XML +#undef SUB_NODE_XML +#undef SUB_NODE_SEQUENCE_XML +#undef SUB_NODE_OPT_XML diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DeclXML.def b/contrib/llvm/tools/clang/include/clang/Frontend/DeclXML.def new file mode 100644 index 0000000..1b158fd --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DeclXML.def @@ -0,0 +1,372 @@ +//===-- DeclXML.def - Metadata about Decl XML nodes ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the XML statement database structure as written in +// <TranslationUnit> sub-nodes of the XML document. +// The semantics of the attributes and enums are mostly self-documenting +// by looking at the appropriate internally used functions and values. +// The following macros are used: +// +// NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete +// statement of class CLASS where CLASS is a class name used internally by clang. +// After a NODE_XML the definition of all (optional) attributes of that statement +// node and possible sub-nodes follows. +// +// END_NODE_XML - Closes the attribute definition of the current node. +// +// ID_ATTRIBUTE_XML - Some statement nodes have an "id" attribute containing a +// string, which value uniquely identify that statement. Other nodes may refer +// by reference attributes to this value (currently used only for Label). +// +// TYPE_ATTRIBUTE_XML( FN ) - Type nodes refer to the result type id of an +// expression by a "type" attribute. FN is internally used by clang. +// +// ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally +// used by clang. A boolean attribute have the values "0" or "1". +// +// ATTRIBUTE_SPECIAL_XML( FN, NAME ) - An attribute named NAME which deserves +// a special handling. See the appropriate documentations. +// +// ATTRIBUTE_FILE_LOCATION_XML - A bunch of attributes denoting the location of +// a statement in the source file(s). +// +// ATTRIBUTE_OPT_XML( FN, NAME ) - An optional attribute named NAME. +// Optional attributes are omitted for boolean types, if the value is false, +// for integral types, if the value is null and for strings, +// if the value is the empty string. FN is internally used by clang. +// +// ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value +// is an enumeration defined with ENUM_XML macros immediately following after +// that macro. An optional attribute is ommited, if the particular enum is the +// empty string. FN is internally used by clang. +// +// ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is +// internally used by clang. +// +// END_ENUM_XML - Closes the enumeration definition of the current attribute. +// +// SUB_NODE_XML( CLASS ) - A mandatory sub-node of class CLASS or its sub-classes. +// +// SUB_NODE_OPT_XML( CLASS ) - An optional sub-node of class CLASS or its sub-classes. +// +// SUB_NODE_SEQUENCE_XML( CLASS ) - Zero or more sub-nodes of class CLASS or +// its sub-classes. +// +//===----------------------------------------------------------------------===// + +#ifndef ATTRIBUTE_FILE_LOCATION_XML +# define ATTRIBUTE_FILE_LOCATION_XML \ + ATTRIBUTE_XML(getFilename(), "file") \ + ATTRIBUTE_XML(getLine(), "line") \ + ATTRIBUTE_XML(getColumn(), "col") \ + ATTRIBUTE_OPT_XML(getFilename(), "endfile") \ + ATTRIBUTE_OPT_XML(getLine(), "endline") \ + ATTRIBUTE_OPT_XML(getColumn(), "endcol") +#endif + +#ifndef TYPE_ATTRIBUTE_XML +# define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type") +#endif + +#ifndef CONTEXT_ATTRIBUTE_XML +# define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context") +#endif + +//NODE_XML(TranslationUnitDecl, "TranslationUnit") +// SUB_NODE_SEQUENCE_XML(Decl) +//END_NODE_XML + +NODE_XML(Decl, "FIXME_Decl") + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclKindName(), "unhandled_decl_name") +END_NODE_XML + +NODE_XML(FunctionDecl, "Function") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType()) + ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type") + ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class") + ENUM_XML(SC_None, "") + ENUM_XML(SC_Extern, "extern") + ENUM_XML(SC_Static, "static") + ENUM_XML(SC_PrivateExtern, "__private_extern__") + END_ENUM_XML + ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") + //ATTRIBUTE_OPT_XML(isVariadic(), "variadic") // in the type reference + ATTRIBUTE_XML(getNumParams(), "num_args") + ATTRIBUTE_OPT_XML(isMain(), "main") + ATTRIBUTE_OPT_XML(isExternC(), "externc") + ATTRIBUTE_OPT_XML(isGlobal(), "global") + SUB_NODE_SEQUENCE_XML(ParmVarDecl) + SUB_NODE_FN_BODY_XML +END_NODE_XML + +NODE_XML(CXXMethodDecl, "CXXMethod") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType()) + ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type") + ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") + ATTRIBUTE_OPT_XML(isStatic(), "static") + ATTRIBUTE_OPT_XML(isVirtual(), "virtual") + ATTRIBUTE_OPT_XML(isPure(), "pure") + ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access") + ENUM_XML(AS_none, "") + ENUM_XML(AS_public, "public") + ENUM_XML(AS_protected, "protected") + ENUM_XML(AS_private, "private") + END_ENUM_XML + ATTRIBUTE_XML(getNumParams(), "num_args") + SUB_NODE_SEQUENCE_XML(ParmVarDecl) + SUB_NODE_FN_BODY_XML +END_NODE_XML + +NODE_XML(CXXConstructorDecl, "CXXConstructor") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType()) + ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type") + ATTRIBUTE_OPT_XML(isExplicit(), "is_explicit") + ATTRIBUTE_OPT_XML(isDefaultConstructor(), "is_default_ctor") + ATTRIBUTE_OPT_XML(isCopyConstructor(), "is_copy_ctor") + ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") + ATTRIBUTE_OPT_XML(isStatic(), "static") + ATTRIBUTE_OPT_XML(isVirtual(), "virtual") + ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access") + ENUM_XML(AS_none, "") + ENUM_XML(AS_public, "public") + ENUM_XML(AS_protected, "protected") + ENUM_XML(AS_private, "private") + END_ENUM_XML + ATTRIBUTE_XML(getNumParams(), "num_args") + SUB_NODE_SEQUENCE_XML(ParmVarDecl) + SUB_NODE_FN_BODY_XML +END_NODE_XML + +NODE_XML(CXXDestructorDecl, "CXXDestructor") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType()) + ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type") + ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") + ATTRIBUTE_OPT_XML(isStatic(), "static") + ATTRIBUTE_OPT_XML(isVirtual(), "virtual") + ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access") + ENUM_XML(AS_none, "") + ENUM_XML(AS_public, "public") + ENUM_XML(AS_protected, "protected") + ENUM_XML(AS_private, "private") + END_ENUM_XML + ATTRIBUTE_XML(getNumParams(), "num_args") + SUB_NODE_SEQUENCE_XML(ParmVarDecl) + SUB_NODE_FN_BODY_XML +END_NODE_XML + +NODE_XML(CXXConversionDecl, "CXXConversion") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType()) + ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type") + ATTRIBUTE_OPT_XML(isExplicit(), "is_explicit") + ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") + ATTRIBUTE_OPT_XML(isStatic(), "static") + ATTRIBUTE_OPT_XML(isVirtual(), "virtual") + ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access") + ENUM_XML(AS_none, "") + ENUM_XML(AS_public, "public") + ENUM_XML(AS_protected, "protected") + ENUM_XML(AS_private, "private") + END_ENUM_XML + ATTRIBUTE_XML(getNumParams(), "num_args") + SUB_NODE_SEQUENCE_XML(ParmVarDecl) + SUB_NODE_FN_BODY_XML +END_NODE_XML + +NODE_XML(NamespaceDecl, "Namespace") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + SUB_NODE_SEQUENCE_XML(DeclContext) +END_NODE_XML + +NODE_XML(UsingDirectiveDecl, "UsingDirective") + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + ATTRIBUTE_XML(getNominatedNamespace(), "ref") +END_NODE_XML + +NODE_XML(NamespaceAliasDecl, "NamespaceAlias") + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + ATTRIBUTE_XML(getNamespace(), "ref") +END_NODE_XML + +NODE_XML(RecordDecl, "Record") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + ATTRIBUTE_OPT_XML(isDefinition() == false, "forward") + ATTRIBUTE_XML(getTypeForDecl(), "type") // refers to the type this decl creates + SUB_NODE_SEQUENCE_XML(FieldDecl) +END_NODE_XML + +NODE_XML(CXXRecordDecl, "CXXRecord") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + ATTRIBUTE_OPT_XML(isDefinition() == false, "forward") + ATTRIBUTE_XML(getTypeForDecl(), "type") // refers to the type this decl creates + SUB_NODE_SEQUENCE_XML(FieldDecl) +END_NODE_XML + +NODE_XML(EnumDecl, "Enum") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + ATTRIBUTE_OPT_XML(isDefinition() == false, "forward") + ATTRIBUTE_SPECIAL_XML(getIntegerType(), "type") // is NULL in pure declarations thus deserves special handling + SUB_NODE_SEQUENCE_XML(EnumConstantDecl) // only present in definition +END_NODE_XML + +NODE_XML(EnumConstantDecl, "EnumConstant") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getInitVal().toString(10, true), "value") // integer + SUB_NODE_OPT_XML(Expr) // init expr of this constant +END_NODE_XML + +NODE_XML(FieldDecl, "Field") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_OPT_XML(isMutable(), "mutable") + ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access") + ENUM_XML(AS_none, "") + ENUM_XML(AS_public, "public") + ENUM_XML(AS_protected, "protected") + ENUM_XML(AS_private, "private") + END_ENUM_XML + ATTRIBUTE_OPT_XML(isBitField(), "bitfield") + SUB_NODE_OPT_XML(Expr) // init expr of a bit field +END_NODE_XML + +NODE_XML(TypedefDecl, "Typedef") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getUnderlyingType()) +END_NODE_XML + +NODE_XML(VarDecl, "Var") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class") + ENUM_XML(SC_None, "") + ENUM_XML(SC_Auto, "auto") + ENUM_XML(SC_Register, "register") + ENUM_XML(SC_Extern, "extern") + ENUM_XML(SC_Static, "static") + ENUM_XML(SC_PrivateExtern, "__private_extern__") + END_ENUM_XML + SUB_NODE_OPT_XML(Expr) // init expr +END_NODE_XML + +NODE_XML(ParmVarDecl, "ParmVar") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_OPT_XML(Expr) // default argument expression +END_NODE_XML + +NODE_XML(LinkageSpecDecl, "LinkageSpec") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_ENUM_OPT_XML(getLanguage(), "lang") + ENUM_XML(LinkageSpecDecl::lang_c, "C") + ENUM_XML(LinkageSpecDecl::lang_cxx, "CXX") + END_ENUM_XML + SUB_NODE_XML(DeclContext) +END_NODE_XML + +NODE_XML(TemplateDecl, "Template") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") +END_NODE_XML + +NODE_XML(TemplateTypeParmDecl, "TemplateTypeParm") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getNameAsString(), "name") +END_NODE_XML + +NODE_XML(UsingShadowDecl, "UsingShadow") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getTargetDecl(), "target_decl") + ATTRIBUTE_XML(getUsingDecl(), "using_decl") +END_NODE_XML + +NODE_XML(UsingDecl, "Using") + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getDeclContext(), "context") + ATTRIBUTE_XML(getTargetNestedNameDecl(), "target_nested_namespace_decl") + ATTRIBUTE_XML(isTypeName(), "is_typename") +END_NODE_XML + +//===----------------------------------------------------------------------===// +#undef NODE_XML +#undef ID_ATTRIBUTE_XML +#undef TYPE_ATTRIBUTE_XML +#undef ATTRIBUTE_XML +#undef ATTRIBUTE_SPECIAL_XML +#undef ATTRIBUTE_OPT_XML +#undef ATTRIBUTE_ENUM_XML +#undef ATTRIBUTE_ENUM_OPT_XML +#undef ATTRIBUTE_FILE_LOCATION_XML +#undef ENUM_XML +#undef END_ENUM_XML +#undef END_NODE_XML +#undef SUB_NODE_XML +#undef SUB_NODE_SEQUENCE_XML +#undef SUB_NODE_OPT_XML +#undef SUB_NODE_FN_BODY_XML diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h new file mode 100644 index 0000000..35aa6c6 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h @@ -0,0 +1,51 @@ +//===--- DependencyOutputOptions.h ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_DEPENDENCYOUTPUTOPTIONS_H +#define LLVM_CLANG_FRONTEND_DEPENDENCYOUTPUTOPTIONS_H + +#include <string> +#include <vector> + +namespace clang { + +/// DependencyOutputOptions - Options for controlling the compiler dependency +/// file generation. +class DependencyOutputOptions { +public: + unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies. + unsigned ShowHeaderIncludes : 1; ///< Show header inclusions (-H). + unsigned UsePhonyTargets : 1; ///< Include phony targets for each + /// dependency, which can avoid some 'make' + /// problems. + + /// The file to write dependency output to. + std::string OutputFile; + + /// The file to write header include output to. This is orthogonal to + /// ShowHeaderIncludes (-H) and will include headers mentioned in the + /// predefines buffer. If the output file is "-", output will be sent to + /// stderr. + std::string HeaderIncludeOutputFile; + + /// A list of names to use as the targets in the dependency file; this list + /// must contain at least one entry. + std::vector<std::string> Targets; + +public: + DependencyOutputOptions() { + IncludeSystemHeaders = 0; + ShowHeaderIncludes = 0; + UsePhonyTargets = 0; + } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h new file mode 100644 index 0000000..f7f498b --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h @@ -0,0 +1,94 @@ +//===--- DiagnosticOptions.h ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_DIAGNOSTICOPTIONS_H +#define LLVM_CLANG_FRONTEND_DIAGNOSTICOPTIONS_H + +#include "clang/Basic/Diagnostic.h" + +#include <string> +#include <vector> + +namespace clang { + +/// DiagnosticOptions - Options for controlling the compiler diagnostics +/// engine. +class DiagnosticOptions { +public: + unsigned IgnoreWarnings : 1; /// -w + unsigned NoRewriteMacros : 1; /// -Wno-rewrite-macros + unsigned Pedantic : 1; /// -pedantic + unsigned PedanticErrors : 1; /// -pedantic-errors + unsigned ShowColumn : 1; /// Show column number on diagnostics. + unsigned ShowLocation : 1; /// Show source location information. + unsigned ShowCarets : 1; /// Show carets in diagnostics. + unsigned ShowFixits : 1; /// Show fixit information. + unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form. + unsigned ShowParseableFixits : 1; /// Show machine parseable fix-its. + unsigned ShowOptionNames : 1; /// Show the diagnostic name for mappable + /// diagnostics. + unsigned ShowCategories : 2; /// Show categories: 0 -> none, 1 -> Number, + /// 2 -> Full Name. + unsigned ShowColors : 1; /// Show diagnostics with ANSI color sequences. + unsigned ShowOverloads : 1; /// Overload candidates to show. Values from + /// Diagnostic::OverloadsShown + unsigned VerifyDiagnostics: 1; /// Check that diagnostics match the expected + /// diagnostics, indicated by markers in the + /// input source file. + + unsigned ErrorLimit; /// Limit # errors emitted. + unsigned MacroBacktraceLimit; /// Limit depth of macro instantiation + /// backtrace. + unsigned TemplateBacktraceLimit; /// Limit depth of instantiation backtrace. + + /// The distance between tab stops. + unsigned TabStop; + enum { DefaultTabStop = 8, MaxTabStop = 100, + DefaultMacroBacktraceLimit = 6, + DefaultTemplateBacktraceLimit = 10 }; + + /// Column limit for formatting message diagnostics, or 0 if unused. + unsigned MessageLength; + + /// If non-empty, a file to log extended build information to, for development + /// testing and analysis. + std::string DumpBuildInformation; + + /// The list of -W... options used to alter the diagnostic mappings, with the + /// prefixes removed. + std::vector<std::string> Warnings; + +public: + DiagnosticOptions() { + IgnoreWarnings = 0; + TabStop = DefaultTabStop; + MessageLength = 0; + NoRewriteMacros = 0; + Pedantic = 0; + PedanticErrors = 0; + ShowCarets = 1; + ShowColors = 0; + ShowOverloads = Diagnostic::Ovl_All; + ShowColumn = 1; + ShowFixits = 1; + ShowLocation = 1; + ShowOptionNames = 0; + ShowCategories = 0; + ShowSourceRanges = 0; + ShowParseableFixits = 0; + VerifyDiagnostics = 0; + ErrorLimit = 0; + TemplateBacktraceLimit = DefaultTemplateBacktraceLimit; + MacroBacktraceLimit = DefaultMacroBacktraceLimit; + } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DocumentXML.def b/contrib/llvm/tools/clang/include/clang/Frontend/DocumentXML.def new file mode 100644 index 0000000..4c52bd8 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DocumentXML.def @@ -0,0 +1,75 @@ +//===-- DocumentXML.def - Metadata about Document XML nodes -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the XML root database structure as written in +// an AST XML document. +// The following macros are used: +// +// NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete +// statement of class CLASS where CLASS is a class name used internally by clang. +// After a NODE_XML the definition of all (optional) attributes of that statement +// node and possible sub-nodes follows. +// +// END_NODE_XML - Closes the attribute definition of the current node. +// +// ID_ATTRIBUTE_XML - Some nodes have an "id" attribute containing a +// string, which value uniquely identify the entity represented by that node. +// Other nodes may refer by reference attributes to this value. +// +// ATTRIBUTE_SPECIAL_XML( FN, NAME ) - An attribute named NAME which deserves +// a special handling. See the appropriate documentations. +// +// SUB_NODE_XML( CLASS ) - A mandatory sub-node of class CLASS or its sub-classes. +// +// SUB_NODE_SEQUENCE_XML( CLASS ) - Zero or more sub-nodes of class CLASS or +// its sub-classes. +// +//===----------------------------------------------------------------------===// + +ROOT_NODE_XML("CLANG_XML") + ATTRIBUTE_SPECIAL_XML(ignore, "version") // special retrieving needed + SUB_NODE_XML("TranslationUnit") + SUB_NODE_XML("ReferenceSection") +END_NODE_XML + +NODE_XML("TranslationUnit") + SUB_NODE_SEQUENCE_XML(Decl) +END_NODE_XML + +NODE_XML("ReferenceSection") + SUB_NODE_XML("Types") + SUB_NODE_XML("Contexts") + SUB_NODE_XML("Files") +END_NODE_XML + +NODE_XML("Types") + SUB_NODE_SEQUENCE_XML(Type) +END_NODE_XML + +NODE_XML("Contexts") + SUB_NODE_SEQUENCE_XML(DeclContext) +END_NODE_XML + +NODE_XML("Files") + SUB_NODE_SEQUENCE_XML("File") +END_NODE_XML + +NODE_XML("File") + ID_ATTRIBUTE_XML + ATTRIBUTE_SPECIAL_XML(ignore, "name") // special retrieving needed, denotes the source file name +END_NODE_XML + + +//===----------------------------------------------------------------------===// +#undef NODE_XML +#undef ID_ATTRIBUTE_XML +#undef ATTRIBUTE_SPECIAL_XML +#undef END_NODE_XML +#undef SUB_NODE_XML +#undef SUB_NODE_SEQUENCE_XML diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DocumentXML.h b/contrib/llvm/tools/clang/include/clang/Frontend/DocumentXML.h new file mode 100644 index 0000000..602d846 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DocumentXML.h @@ -0,0 +1,185 @@ +//===--- DocumentXML.h - XML document for ASTs ------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_DOCUMENTXML_H +#define LLVM_CLANG_FRONTEND_DOCUMENTXML_H + +#include <string> +#include <map> +#include <stack> +#include "clang/AST/Type.h" +#include "clang/AST/TypeOrdering.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/DenseMap.h" + +namespace clang { + +//--------------------------------------------------------- forwards +class DeclContext; +class Decl; +class NamedDecl; +class FunctionDecl; +class ASTContext; +class LabelStmt; + +//--------------------------------------------------------- +namespace XML { + // id maps: + template<class T> + struct IdMap : llvm::DenseMap<T, unsigned> {}; + + template<> + struct IdMap<QualType> : std::map<QualType, unsigned, QualTypeOrdering> {}; + + template<> + struct IdMap<std::string> : std::map<std::string, unsigned> {}; +} + +//--------------------------------------------------------- +class DocumentXML { +public: + DocumentXML(const std::string& rootName, llvm::raw_ostream& out); + + void initialize(ASTContext &Context); + void PrintDecl(Decl *D); + void PrintStmt(const Stmt *S); // defined in StmtXML.cpp + void finalize(); + + + 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, bool value); + + template<class T> + void addAttribute(const char* pName, const T* value) { + addPtrAttribute(pName, value); + } + + template<class T> + 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); + + void addSourceFileAttribute(const std::string& fileName); + + PresumedLoc addLocation(const SourceLocation& Loc); + void addLocationRange(const SourceRange& R); + + static std::string escapeString(const char* pStr, std::string::size_type len); + +private: + DocumentXML(const DocumentXML&); // not defined + DocumentXML& operator=(const DocumentXML&); // not defined + + std::stack<std::string> NodeStack; + llvm::raw_ostream& Out; + ASTContext *Ctx; + bool HasCurrentNodeSubNodes; + + + XML::IdMap<QualType> Types; + XML::IdMap<const DeclContext*> Contexts; + XML::IdMap<const Type*> BasicTypes; + XML::IdMap<std::string> SourceFiles; + XML::IdMap<const NamedDecl*> Decls; + XML::IdMap<const LabelStmt*> Labels; + + void addContextsRecursively(const DeclContext *DC); + void addTypeRecursively(const Type* pType); + void addTypeRecursively(const QualType& pType); + + void Indent(); + + // forced pointer dispatch: + 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 + void addPtrAttribute(const char* pName, const NestedNameSpecifier* N); + void addPtrAttribute(const char* pName, const LabelStmt* L); + void addPtrAttribute(const char* pName, const char* text); + + // defined in TypeXML.cpp: + void addParentTypes(const Type* pType); + void writeTypeToXML(const Type* pType); + void writeTypeToXML(const QualType& pType); + class TypeAdder; + friend class TypeAdder; + + // defined in DeclXML.cpp: + void writeDeclToXML(Decl *D); + class DeclPrinter; + friend class DeclPrinter; + + // 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; +} + +//--------------------------------------------------------- +template<class T> +inline void DocumentXML::addAttribute(const char* pName, const T& value) { + std::string repr; + { + llvm::raw_string_ostream buf(repr); + buf << value; + } + + Out << ' ' << pName << "=\"" + << DocumentXML::escapeString(repr.c_str(), repr.size()) + << "\""; +} + +//--------------------------------------------------------- +inline void DocumentXML::addPtrAttribute(const char* pName, const char* text) { + Out << ' ' << pName << "=\"" + << DocumentXML::escapeString(text, strlen(text)) + << "\""; +} + +//--------------------------------------------------------- +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)) { + addAttribute(pName, value); + } +} + +//--------------------------------------------------------- + +} //namespace clang + +#endif //LLVM_CLANG_DOCUMENTXML_H diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h new file mode 100644 index 0000000..ee0863a --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h @@ -0,0 +1,258 @@ +//===-- FrontendAction.h - Generic Frontend Action Interface ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_FRONTENDACTION_H +#define LLVM_CLANG_FRONTEND_FRONTENDACTION_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/OwningPtr.h" +#include <string> +#include <vector> + +namespace llvm { + class raw_ostream; +} + +namespace clang { +class ASTConsumer; +class ASTMergeAction; +class ASTUnit; +class CompilerInstance; + +enum InputKind { + IK_None, + IK_Asm, + IK_C, + IK_CXX, + IK_ObjC, + IK_ObjCXX, + IK_PreprocessedC, + IK_PreprocessedCXX, + IK_PreprocessedObjC, + IK_PreprocessedObjCXX, + IK_OpenCL, + IK_CUDA, + IK_AST, + IK_LLVM_IR +}; + + +/// FrontendAction - Abstract base class for actions which can be performed by +/// the frontend. +class FrontendAction { + std::string CurrentFile; + InputKind CurrentFileKind; + llvm::OwningPtr<ASTUnit> CurrentASTUnit; + CompilerInstance *Instance; + friend class ASTMergeAction; + +private: + ASTConsumer* CreateWrappedASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + +protected: + /// @name Implementation Action Interface + /// @{ + + /// CreateASTConsumer - Create the AST consumer object for this action, if + /// supported. + /// + /// This routine is called as part of \see BeginSourceAction(), which will + /// fail if the AST consumer cannot be created. This will not be called if the + /// action has indicated that it only uses the preprocessor. + /// + /// \param CI - The current compiler instance, provided as a convenience, \see + /// getCompilerInstance(). + /// + /// \param InFile - The current input file, provided as a convenience, \see + /// getCurrentFile(). + /// + /// \return The new AST consumer, or 0 on failure. + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile) = 0; + + /// BeginSourceFileAction - Callback at the start of processing a single + /// input. + /// + /// \return True on success; on failure \see ExecutionAction() and + /// EndSourceFileAction() will not be called. + virtual bool BeginSourceFileAction(CompilerInstance &CI, + llvm::StringRef Filename) { + return true; + } + + /// ExecuteAction - Callback to run the program action, using the initialized + /// compiler instance. + /// + /// This routine is guaranteed to only be called between \see + /// BeginSourceFileAction() and \see EndSourceFileAction(). + virtual void ExecuteAction() = 0; + + /// EndSourceFileAction - Callback at the end of processing a single input; + /// this is guaranteed to only be called following a successful call to + /// BeginSourceFileAction (and BeingSourceFile). + virtual void EndSourceFileAction() {} + + /// @} + +public: + FrontendAction(); + virtual ~FrontendAction(); + + /// @name Compiler Instance Access + /// @{ + + CompilerInstance &getCompilerInstance() const { + assert(Instance && "Compiler instance not registered!"); + return *Instance; + } + + void setCompilerInstance(CompilerInstance *Value) { Instance = Value; } + + /// @} + /// @name Current File Information + /// @{ + + bool isCurrentFileAST() const { + assert(!CurrentFile.empty() && "No current file!"); + return CurrentASTUnit != 0; + } + + const std::string &getCurrentFile() const { + assert(!CurrentFile.empty() && "No current file!"); + return CurrentFile; + } + + InputKind getCurrentFileKind() const { + assert(!CurrentFile.empty() && "No current file!"); + return CurrentFileKind; + } + + ASTUnit &getCurrentASTUnit() const { + assert(CurrentASTUnit && "No current AST unit!"); + return *CurrentASTUnit; + } + + ASTUnit *takeCurrentASTUnit() { + return CurrentASTUnit.take(); + } + + void setCurrentFile(llvm::StringRef Value, InputKind Kind, ASTUnit *AST = 0); + + /// @} + /// @name Supported Modes + /// @{ + + /// usesPreprocessorOnly - Does this action only use the preprocessor? If so + /// no AST context will be created and this action will be invalid with AST + /// file inputs. + virtual bool usesPreprocessorOnly() const = 0; + + /// usesCompleteTranslationUnit - For AST based actions, should the + /// translation unit be completed? + virtual bool usesCompleteTranslationUnit() { return true; } + + /// hasPCHSupport - Does this action support use with PCH? + virtual bool hasPCHSupport() const { return !usesPreprocessorOnly(); } + + /// hasASTFileSupport - Does this action support use with AST files? + virtual bool hasASTFileSupport() const { return !usesPreprocessorOnly(); } + + /// hasIRSupport - Does this action support use with IR files? + virtual bool hasIRSupport() const { return false; } + + /// hasCodeCompletionSupport - Does this action support use with code + /// completion? + virtual bool hasCodeCompletionSupport() const { return false; } + + /// @} + /// @name Public Action Interface + /// @{ + + /// BeginSourceFile - Prepare the action for processing the input file \arg + /// Filename; this is run after the options and frontend have been + /// initialized, but prior to executing any per-file processing. + /// + /// \param CI - The compiler instance this action is being run from. The + /// action may store and use this object up until the matching EndSourceFile + /// action. + /// + /// \param Filename - The input filename, which will be made available to + /// clients via \see getCurrentFile(). + /// + /// \param InputKind - The type of input. Some input kinds are handled + /// specially, for example AST inputs, since the AST file itself contains + /// several objects which would normally be owned by the + /// CompilerInstance. When processing AST input files, these objects should + /// generally not be initialized in the CompilerInstance -- they will + /// automatically be shared with the AST file in between \see + /// BeginSourceFile() and \see EndSourceFile(). + /// + /// \return True on success; the compilation of this file should be aborted + /// and neither Execute nor EndSourceFile should be called. + bool BeginSourceFile(CompilerInstance &CI, llvm::StringRef Filename, + InputKind Kind); + + /// Execute - Set the source managers main input file, and run the action. + void Execute(); + + /// EndSourceFile - Perform any per-file post processing, deallocate per-file + /// objects, and run statistics and output file cleanup code. + void EndSourceFile(); + + /// @} +}; + +/// ASTFrontendAction - Abstract base class to use for AST consumer based +/// frontend actions. +class ASTFrontendAction : public FrontendAction { +protected: + /// ExecuteAction - Implement the ExecuteAction interface by running Sema on + /// the already initialized AST consumer. + /// + /// This will also take care of instantiating a code completion consumer if + /// the user requested it and the action supports it. + virtual void ExecuteAction(); + +public: + virtual bool usesPreprocessorOnly() const { return false; } +}; + +class PluginASTAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile) = 0; + +public: + /// ParseArgs - Parse the given plugin command line arguments. + /// + /// \param CI - The compiler instance, for use in reporting diagnostics. + /// \return True if the parsing succeeded; otherwise the plugin will be + /// destroyed and no action run. The plugin is responsible for using the + /// CompilerInstance's Diagnostic object to report errors. + virtual bool ParseArgs(const CompilerInstance &CI, + const std::vector<std::string> &arg) = 0; +}; + +/// PreprocessorFrontendAction - Abstract base class to use for preprocessor +/// based frontend actions. +class PreprocessorFrontendAction : public FrontendAction { +protected: + /// CreateASTConsumer - Provide a default implementation which returns aborts, + /// this method should never be called by FrontendAction clients. + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + +public: + virtual bool usesPreprocessorOnly() const { return true; } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h new file mode 100644 index 0000000..4df2e71 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h @@ -0,0 +1,192 @@ +//===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H +#define LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H + +#include "clang/Frontend/FrontendAction.h" +#include <string> +#include <vector> + +namespace clang { + +//===----------------------------------------------------------------------===// +// Custom Consumer Actions +//===----------------------------------------------------------------------===// + +class InitOnlyAction : public FrontendAction { + virtual void ExecuteAction(); + + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + +public: + // Don't claim to only use the preprocessor, we want to follow the AST path, + // but do nothing. + virtual bool usesPreprocessorOnly() const { return false; } +}; + +//===----------------------------------------------------------------------===// +// AST Consumer Actions +//===----------------------------------------------------------------------===// + +class ASTPrintAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +class ASTPrintXMLAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +class ASTDumpAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +class ASTDumpXMLAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +class ASTViewAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +class DeclContextPrintAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +class GeneratePCHAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + + virtual bool usesCompleteTranslationUnit() { return false; } + + virtual bool hasASTFileSupport() const { return false; } + +public: + /// \brief Compute the AST consumer arguments that will be used to + /// create the PCHGenerator instance returned by CreateASTConsumer. + /// + /// \returns true if an error occurred, false otherwise. + static bool ComputeASTConsumerArguments(CompilerInstance &CI, + llvm::StringRef InFile, + std::string &Sysroot, + std::string &OutputFile, + llvm::raw_ostream *&OS, + bool &Chaining); +}; + +class SyntaxOnlyAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + +public: + virtual bool hasCodeCompletionSupport() const { return true; } +}; + +class BoostConAction : public SyntaxOnlyAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + +/** + * \brief Frontend action adaptor that merges ASTs together. + * + * This action takes an existing AST file and "merges" it into the AST + * context, producing a merged context. This action is an action + * adaptor, which forwards most of its calls to another action that + * will consume the merged context. + */ +class ASTMergeAction : public FrontendAction { + /// \brief The action that the merge action adapts. + FrontendAction *AdaptedAction; + + /// \brief The set of AST files to merge. + std::vector<std::string> ASTFiles; + +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + + virtual bool BeginSourceFileAction(CompilerInstance &CI, + llvm::StringRef Filename); + + virtual void ExecuteAction(); + virtual void EndSourceFileAction(); + +public: + ASTMergeAction(FrontendAction *AdaptedAction, + std::string *ASTFiles, unsigned NumASTFiles); + virtual ~ASTMergeAction(); + + virtual bool usesPreprocessorOnly() const; + virtual bool usesCompleteTranslationUnit(); + virtual bool hasPCHSupport() const; + virtual bool hasASTFileSupport() const; + virtual bool hasCodeCompletionSupport() const; +}; + +class PrintPreambleAction : public FrontendAction { +protected: + void ExecuteAction(); + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &, llvm::StringRef) { + return 0; + } + + virtual bool usesPreprocessorOnly() const { return true; } +}; + +//===----------------------------------------------------------------------===// +// Preprocessor Actions +//===----------------------------------------------------------------------===// + +class DumpRawTokensAction : public PreprocessorFrontendAction { +protected: + void ExecuteAction(); +}; + +class DumpTokensAction : public PreprocessorFrontendAction { +protected: + void ExecuteAction(); +}; + +class GeneratePTHAction : public PreprocessorFrontendAction { +protected: + void ExecuteAction(); +}; + +class PreprocessOnlyAction : public PreprocessorFrontendAction { +protected: + void ExecuteAction(); +}; + +class PrintPreprocessedAction : public PreprocessorFrontendAction { +protected: + void ExecuteAction(); + + virtual bool hasPCHSupport() const { return true; } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h new file mode 100644 index 0000000..2efbc81 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h @@ -0,0 +1,27 @@ +//===--- DiagnosticFrontend.h - Diagnostics for frontend --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTENDDIAGNOSTIC_H +#define LLVM_CLANG_FRONTENDDIAGNOSTIC_H + +#include "clang/Basic/Diagnostic.h" + +namespace clang { + namespace diag { + enum { +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM, +#define FRONTENDSTART +#include "clang/Basic/DiagnosticFrontendKinds.inc" +#undef DIAG + NUM_BUILTIN_FRONTEND_DIAGNOSTICS + }; + } // end namespace diag +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h new file mode 100644 index 0000000..19d39c3 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h @@ -0,0 +1,147 @@ +//===--- FrontendOptions.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H +#define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H + +#include "clang/Frontend/CommandLineSourceLoc.h" +#include "clang/Frontend/FrontendAction.h" +#include "llvm/ADT/StringRef.h" +#include <string> +#include <vector> + +namespace clang { + +namespace frontend { + enum ActionKind { + ASTDump, ///< Parse ASTs and dump them. + ASTDumpXML, ///< Parse ASTs and dump them in XML. + ASTPrint, ///< Parse ASTs and print them. + ASTPrintXML, ///< Parse ASTs and print them in XML. + ASTView, ///< Parse ASTs and view them in Graphviz. + BoostCon, ///< BoostCon mode. + CreateModule, ///< Create module definition + DumpRawTokens, ///< Dump out raw tokens. + DumpTokens, ///< Dump out preprocessed tokens. + EmitAssembly, ///< Emit a .s file. + EmitBC, ///< Emit a .bc file. + EmitHTML, ///< Translate input source into HTML. + EmitLLVM, ///< Emit a .ll file. + EmitLLVMOnly, ///< Generate LLVM IR, but do not emit anything. + EmitCodeGenOnly, ///< Generate machine code, but don't emit anything. + EmitObj, ///< Emit a .o file. + FixIt, ///< Parse and apply any fixits to the source. + GeneratePCH, ///< Generate pre-compiled header. + GeneratePTH, ///< Generate pre-tokenized header. + InitOnly, ///< Only execute frontend initialization. + ParseSyntaxOnly, ///< Parse and perform semantic analysis. + PluginAction, ///< Run a plugin action, \see ActionName. + PrintDeclContext, ///< Print DeclContext and their Decls. + PrintPreamble, ///< Print the "preamble" of the input file + PrintPreprocessedInput, ///< -E mode. + RewriteMacros, ///< Expand macros but not #includes. + RewriteObjC, ///< ObjC->C Rewriter. + RewriteTest, ///< Rewriter playground + RunAnalysis, ///< Run one or more source code analyses. + RunPreprocessorOnly ///< Just lex, no output. + }; +} + +/// FrontendOptions - Options for controlling the behavior of the frontend. +class FrontendOptions { +public: + unsigned DisableFree : 1; ///< Disable memory freeing on exit. + unsigned RelocatablePCH : 1; ///< When generating PCH files, + /// instruct the AST writer to create + /// relocatable PCH files. + unsigned ChainedPCH : 1; ///< When generating PCH files, + /// instruct the AST writer to create + /// chained PCH files. + unsigned ShowHelp : 1; ///< Show the -help text. + unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion + /// results. + unsigned ShowCodePatternsInCodeCompletion : 1; ///< Show code patterns in code + /// completion results. + unsigned ShowGlobalSymbolsInCodeCompletion : 1; ///< Show top-level decls 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. + unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are + /// unfixable errors. + + /// The input files and their types. + std::vector<std::pair<InputKind, std::string> > Inputs; + + /// The output file, if any. + std::string OutputFile; + + /// If given, the new suffix for fix-it rewritten files. + std::string FixItSuffix; + + /// If given, enable code completion at the provided location. + ParsedSourceLocation CodeCompletionAt; + + /// The frontend action to perform. + frontend::ActionKind ProgramAction; + + /// The name of the action to run when using a plugin action. + std::string ActionName; + + /// Args to pass to the plugin + std::vector<std::string> PluginArgs; + + /// The list of plugin actions to run in addition to the normal action. + std::vector<std::string> AddPluginActions; + + /// Args to pass to the additional plugins + std::vector<std::vector<std::string> > AddPluginArgs; + + /// The list of plugins to load. + std::vector<std::string> Plugins; + + /// \brief The list of AST files to merge. + std::vector<std::string> ASTMergeFiles; + + /// \brief The list of modules to import. + std::vector<std::string> Modules; + + /// \brief A list of arguments to forward to LLVM's option processing; this + /// should only be used for debugging and experimental features. + std::vector<std::string> LLVMArgs; + +public: + FrontendOptions() { + DisableFree = 0; + ProgramAction = frontend::ParseSyntaxOnly; + ActionName = ""; + RelocatablePCH = 0; + ChainedPCH = 0; + ShowHelp = 0; + ShowMacrosInCodeCompletion = 0; + ShowCodePatternsInCodeCompletion = 0; + ShowGlobalSymbolsInCodeCompletion = 1; + ShowStats = 0; + ShowTimers = 0; + ShowVersion = 0; + } + + /// getInputKindForExtension - Return the appropriate input kind for a file + /// extension. For example, "c" would return IK_C. + /// + /// \return The input kind for the extension, or IK_None if the extension is + /// not recognized. + static InputKind getInputKindForExtension(llvm::StringRef Extension); +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h new file mode 100644 index 0000000..ec925ad --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h @@ -0,0 +1,23 @@ +//===-- FrontendAction.h - Pluggable Frontend Action Interface --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_PLUGINFRONTENDACTION_H +#define LLVM_CLANG_FRONTEND_PLUGINFRONTENDACTION_H + +#include "clang/Frontend/FrontendAction.h" +#include "llvm/Support/Registry.h" + +namespace clang { + +/// The frontend plugin registry. +typedef llvm::Registry<PluginASTAction> FrontendPluginRegistry; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h new file mode 100644 index 0000000..cbb4a57 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h @@ -0,0 +1,104 @@ +//===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H +#define LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H + +#include "llvm/ADT/StringRef.h" +#include <vector> + +namespace clang { + +namespace frontend { + /// IncludeDirGroup - Identifiers the group a include entry belongs to, which + /// represents its relative positive in the search list. + enum IncludeDirGroup { + Quoted = 0, ///< `#include ""` paths. Thing `gcc -iquote`. + Angled, ///< Paths for both `#include ""` and `#include <>`. (`-I`) + System, ///< Like Angled, but marks system directories. + After ///< Like System, but searched after the system directories. + }; +} + +/// HeaderSearchOptions - Helper class for storing options related to the +/// initialization of the HeaderSearch object. +class HeaderSearchOptions { +public: + struct Entry { + std::string Path; + frontend::IncludeDirGroup Group; + unsigned IsUserSupplied : 1; + unsigned IsFramework : 1; + + /// IsSysRootRelative - This is true if an absolute path should be treated + /// relative to the sysroot, or false if it should always be the absolute + /// path. + unsigned IsSysRootRelative : 1; + + Entry(llvm::StringRef path, frontend::IncludeDirGroup group, + bool isUserSupplied, bool isFramework, bool isSysRootRelative) + : Path(path), Group(group), IsUserSupplied(isUserSupplied), + IsFramework(isFramework), IsSysRootRelative(isSysRootRelative) {} + }; + + /// If non-empty, the directory to use as a "virtual system root" for include + /// paths. + std::string Sysroot; + + /// User specified include entries. + std::vector<Entry> UserEntries; + + /// If non-empty, the list of C++ standard include paths to use. + std::vector<std::string> CXXSystemIncludes; + + /// A (system-path) delimited list of include paths to be added from the + /// environment following the user specified includes (but prior to builtin + /// and standard includes). This is parsed in the same manner as the CPATH + /// environment variable for gcc. + std::string EnvIncPath; + + /// Per-language environmental include paths, see \see EnvIncPath. + std::string CEnvIncPath; + std::string ObjCEnvIncPath; + std::string CXXEnvIncPath; + std::string ObjCXXEnvIncPath; + + /// 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; + + /// Include the system standard C++ library include search directories. + unsigned UseStandardCXXIncludes : 1; + + /// Whether header search information should be output as for -v. + unsigned Verbose : 1; + +public: + HeaderSearchOptions(llvm::StringRef _Sysroot = "/") + : Sysroot(_Sysroot), UseBuiltinIncludes(true), + UseStandardIncludes(true), UseStandardCXXIncludes(true), + Verbose(false) {} + + /// AddPath - Add the \arg Path path to the specified \arg Group list. + void AddPath(llvm::StringRef Path, frontend::IncludeDirGroup Group, + bool IsUserSupplied, bool IsFramework, bool IsSysRootRelative) { + UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework, + IsSysRootRelative)); + } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h new file mode 100644 index 0000000..441d34f --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h @@ -0,0 +1,83 @@ +//===--- LangStandard.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H +#define LLVM_CLANG_FRONTEND_LANGSTANDARD_H + +#include "llvm/ADT/StringRef.h" + +namespace clang { + +namespace frontend { + +enum LangFeatures { + BCPLComment = (1 << 0), + C99 = (1 << 1), + CPlusPlus = (1 << 2), + CPlusPlus0x = (1 << 3), + Digraphs = (1 << 4), + GNUMode = (1 << 5), + HexFloat = (1 << 6), + ImplicitInt = (1 << 7) +}; + +} + +/// LangStandard - Information about the properties of a particular language +/// standard. +struct LangStandard { + enum Kind { +#define LANGSTANDARD(id, name, desc, features) \ + lang_##id, +#include "clang/Frontend/LangStandards.def" + lang_unspecified + }; + + const char *ShortName; + const char *Description; + unsigned Flags; + +public: + /// getName - Get the name of this standard. + const char *getName() const { return ShortName; } + + /// getDescription - Get the description of this standard. + const char *getDescription() const { return Description; } + + /// hasBCPLComments - Language supports '//' comments. + bool hasBCPLComments() const { return Flags & frontend::BCPLComment; } + + /// isC99 - Language is a superset of C99. + bool isC99() const { return Flags & frontend::C99; } + + /// isCPlusPlus - Language is a C++ variant. + bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } + + /// isCPlusPlus0x - Language is a C++0x variant. + bool isCPlusPlus0x() const { return Flags & frontend::CPlusPlus0x; } + + /// hasDigraphs - Language supports digraphs. + bool hasDigraphs() const { return Flags & frontend::Digraphs; } + + /// isGNUMode - Language includes GNU extensions. + bool isGNUMode() const { return Flags & frontend::GNUMode; } + + /// hasHexFloats - Language supports hexadecimal float constants. + bool hasHexFloats() const { return Flags & frontend::HexFloat; } + + /// hasImplicitInt - Language allows variables to be typed as int implicitly. + bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; } + + static const LangStandard &getLangStandardForKind(Kind K); + static const LangStandard *getLangStandardForName(llvm::StringRef Name); +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def new file mode 100644 index 0000000..d4046b3 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def @@ -0,0 +1,88 @@ +//===-- LangStandards.def - Language Standard Data --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LANGSTANDARD +#error "LANGSTANDARD must be defined before including this file" +#endif + +/// LANGSTANDARD(IDENT, NAME, DESC, FEATURES) +/// +/// \param IDENT - The name of the standard as a C++ identifier. +/// \param NAME - The name of the standard. +/// \param DESC - A short description of the standard. +/// \param FEATURES - The standard features as flags, these are enums from the +/// clang::frontend namespace, which is assumed to be be available. + +// C89-ish modes. +LANGSTANDARD(c89, "c89", + "ISO C 1990", + ImplicitInt) +LANGSTANDARD(c90, "c90", + "ISO C 1990", + ImplicitInt) +LANGSTANDARD(iso9899_1990, "iso9899:1990", + "ISO C 1990", + ImplicitInt) + +LANGSTANDARD(c94, "iso9899:199409", + "ISO C 1990 with amendment 1", + Digraphs | ImplicitInt) + +LANGSTANDARD(gnu89, "gnu89", + "ISO C 1990 with GNU extensions", + BCPLComment | Digraphs | GNUMode | ImplicitInt) + +// C99-ish modes +LANGSTANDARD(c99, "c99", + "ISO C 1999", + BCPLComment | C99 | Digraphs | HexFloat) +LANGSTANDARD(c9x, "c9x", + "ISO C 1999", + BCPLComment | C99 | Digraphs | HexFloat) +LANGSTANDARD(iso9899_1999, + "iso9899:1999", "ISO C 1999", + BCPLComment | C99 | Digraphs | HexFloat) +LANGSTANDARD(iso9899_199x, + "iso9899:199x", "ISO C 1999", + BCPLComment | C99 | Digraphs | HexFloat) + +LANGSTANDARD(gnu99, "gnu99", + "ISO C 1999 with GNU extensions", + BCPLComment | C99 | Digraphs | GNUMode | HexFloat | Digraphs) +LANGSTANDARD(gnu9x, "gnu9x", + "ISO C 1999 with GNU extensions", + BCPLComment | C99 | Digraphs | GNUMode | HexFloat) + +// C++ modes +LANGSTANDARD(cxx98, "c++98", + "ISO C++ 1998 with amendments", + BCPLComment | CPlusPlus | Digraphs) +LANGSTANDARD(gnucxx98, "gnu++98", + "ISO C++ 1998 with " "amendments and GNU extensions", + BCPLComment | CPlusPlus | Digraphs | GNUMode) + +LANGSTANDARD(cxx0x, "c++0x", + "Upcoming ISO C++ 200x with amendments", + BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs) +LANGSTANDARD(gnucxx0x, "gnu++0x", + "Upcoming ISO C++ 200x with amendments and GNU extensions", + BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) + +// OpenCL + +LANGSTANDARD(opencl, "cl", + "OpenCL 1.0", + BCPLComment | C99 | Digraphs | HexFloat) + +// CUDA +LANGSTANDARD(cuda, "cuda", + "NVIDIA CUDA(tm)", + BCPLComment | CPlusPlus | Digraphs) + +#undef LANGSTANDARD diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h b/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h new file mode 100644 index 0000000..560178b --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h @@ -0,0 +1,54 @@ +//===-- MultiplexConsumer.h - AST Consumer for PCH Generation ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the MultiplexConsumer class, which can be used to +// multiplex ASTConsumer and SemaConsumer messages to many consumers. +// +//===----------------------------------------------------------------------===// + +#include "clang/Sema/SemaConsumer.h" +#include "llvm/ADT/OwningPtr.h" +#include <vector> + +namespace clang { + +class MultiplexASTMutationListener; +class MultiplexASTDeserializationListener; + +// Has a list of ASTConsumers and calls each of them. Owns its children. +class MultiplexConsumer : public SemaConsumer { +public: + // Takes ownership of the pointers in C. + MultiplexConsumer(const std::vector<ASTConsumer*>& C); + ~MultiplexConsumer(); + + // ASTConsumer + virtual void Initialize(ASTContext &Context); + virtual void HandleTopLevelDecl(DeclGroupRef D); + virtual void HandleInterestingDecl(DeclGroupRef D); + virtual void HandleTranslationUnit(ASTContext &Ctx); + virtual void HandleTagDeclDefinition(TagDecl *D); + virtual void CompleteTentativeDefinition(VarDecl *D); + virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired); + virtual ASTMutationListener *GetASTMutationListener(); + virtual ASTDeserializationListener *GetASTDeserializationListener(); + virtual void PrintStats(); + + // SemaConsumer + virtual void InitializeSema(Sema &S); + virtual void ForgetSema(); + + static bool classof(const MultiplexConsumer *) { return true; } +private: + std::vector<ASTConsumer*> Consumers; // Owns these. + llvm::OwningPtr<MultiplexASTMutationListener> MutationListener; + llvm::OwningPtr<MultiplexASTDeserializationListener> DeserializationListener; +}; + +} // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOptions.h new file mode 100644 index 0000000..0d52e53 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOptions.h @@ -0,0 +1,168 @@ +//===--- PreprocessorOptionms.h ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_ +#define LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_ + +#include "llvm/ADT/StringRef.h" +#include <cassert> +#include <string> +#include <utility> +#include <vector> +#include <set> + +namespace llvm { + class MemoryBuffer; +} + +namespace clang { + +class Preprocessor; +class LangOptions; + +/// PreprocessorOptions - This class is used for passing the various options +/// used in preprocessor initialization to InitializePreprocessor(). +class PreprocessorOptions { +public: + std::vector<std::pair<std::string, bool/*isUndef*/> > Macros; + std::vector<std::string> Includes; + std::vector<std::string> MacroIncludes; + + unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler + /// and target specific predefines. + + unsigned DetailedRecord : 1; /// Whether we should maintain a detailed + /// record of all macro definitions and + /// instantiations. + + /// The implicit PCH included at the start of the translation unit, or empty. + std::string ImplicitPCHInclude; + + /// \brief When true, disables most of the normal validation performed on + /// precompiled headers. + bool DisablePCHValidation; + + /// \brief When true, disables the use of the stat cache within a + /// precompiled header or AST file. + bool DisableStatCache; + + /// \brief Dump declarations that are deserialized from PCH, for testing. + bool DumpDeserializedPCHDecls; + + /// \brief This is a set of names for decls that we do not want to be + /// deserialized, and we emit an error if they are; for testing purposes. + std::set<std::string> DeserializedPCHDeclsToErrorOn; + + /// \brief If non-zero, the implicit PCH include is actually a precompiled + /// preamble that covers this number of bytes in the main source file. + /// + /// The boolean indicates whether the preamble ends at the start of a new + /// line. + std::pair<unsigned, bool> PrecompiledPreambleBytes; + + /// The implicit PTH input included at the start of the translation unit, or + /// empty. + std::string ImplicitPTHInclude; + + /// 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; + + /// \brief The set of file-to-buffer remappings, which take existing files + /// on the system (the first part of each pair) and gives them the contents + /// of the specified memory buffer (the second part of each pair). + std::vector<std::pair<std::string, const llvm::MemoryBuffer *> > + RemappedFileBuffers; + + /// \brief Whether the compiler instance should retain (i.e., not free) + /// the buffers associated with remapped files. + /// + /// This flag defaults to false; it can be set true only through direct + /// manipulation of the compiler invocation object, in cases where the + /// compiler invocation and its buffers will be reused. + bool RetainRemappedFileBuffers; + + typedef std::vector<std::pair<std::string, std::string> >::iterator + remapped_file_iterator; + typedef std::vector<std::pair<std::string, std::string> >::const_iterator + const_remapped_file_iterator; + remapped_file_iterator remapped_file_begin() { + return RemappedFiles.begin(); + } + const_remapped_file_iterator remapped_file_begin() const { + return RemappedFiles.begin(); + } + remapped_file_iterator remapped_file_end() { + return RemappedFiles.end(); + } + const_remapped_file_iterator remapped_file_end() const { + return RemappedFiles.end(); + } + + typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >:: + iterator remapped_file_buffer_iterator; + typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >:: + const_iterator const_remapped_file_buffer_iterator; + remapped_file_buffer_iterator remapped_file_buffer_begin() { + return RemappedFileBuffers.begin(); + } + const_remapped_file_buffer_iterator remapped_file_buffer_begin() const { + return RemappedFileBuffers.begin(); + } + remapped_file_buffer_iterator remapped_file_buffer_end() { + return RemappedFileBuffers.end(); + } + const_remapped_file_buffer_iterator remapped_file_buffer_end() const { + return RemappedFileBuffers.end(); + } + +public: + PreprocessorOptions() : UsePredefines(true), DetailedRecord(false), + DisablePCHValidation(false), DisableStatCache(false), + DumpDeserializedPCHDecls(false), + PrecompiledPreambleBytes(0, true), + RetainRemappedFileBuffers(false) { } + + void addMacroDef(llvm::StringRef Name) { + Macros.push_back(std::make_pair(Name, false)); + } + 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)); + } + + remapped_file_iterator eraseRemappedFile(remapped_file_iterator Remapped) { + return RemappedFiles.erase(Remapped); + } + + void addRemappedFile(llvm::StringRef From, const llvm::MemoryBuffer * To) { + RemappedFileBuffers.push_back(std::make_pair(From, To)); + } + + remapped_file_buffer_iterator + eraseRemappedFile(remapped_file_buffer_iterator Remapped) { + return RemappedFileBuffers.erase(Remapped); + } + + void clearRemappedFiles() { + RemappedFiles.clear(); + RemappedFileBuffers.clear(); + } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h new file mode 100644 index 0000000..1eda0d4 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h @@ -0,0 +1,37 @@ +//===--- PreprocessorOutputOptions.h ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROUTPUTOPTIONS_H +#define LLVM_CLANG_FRONTEND_PREPROCESSOROUTPUTOPTIONS_H + +namespace clang { + +/// PreprocessorOutputOptions - Options for controlling the C preprocessor +/// output (e.g., -E). +class PreprocessorOutputOptions { +public: + unsigned ShowCPP : 1; ///< Print normal preprocessed output. + unsigned ShowComments : 1; ///< Show comments. + unsigned ShowLineMarkers : 1; ///< Show #line markers. + unsigned ShowMacroComments : 1; ///< Show comments, even in macros. + unsigned ShowMacros : 1; ///< Print macro definitions. + +public: + PreprocessorOutputOptions() { + ShowCPP = 1; + ShowComments = 0; + ShowLineMarkers = 1; + ShowMacroComments = 0; + ShowMacros = 0; + } +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/StmtXML.def b/contrib/llvm/tools/clang/include/clang/Frontend/StmtXML.def new file mode 100644 index 0000000..8a859e6 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/StmtXML.def @@ -0,0 +1,520 @@ +//===-- StmtXML.def - Metadata about Stmt XML nodes ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the XML statement database structure as written in +// <TranslationUnit> sub-nodes of the XML document. +// The semantics of the attributes and enums are mostly self-documenting +// by looking at the appropriate internally used functions and values. +// The following macros are used: +// +// NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete +// statement of class CLASS where CLASS is a class name used internally by clang. +// After a NODE_XML the definition of all (optional) attributes of that statement +// node and possible sub-nodes follows. +// +// END_NODE_XML - Closes the attribute definition of the current node. +// +// ID_ATTRIBUTE_XML - Some statement nodes have an "id" attribute containing a +// string, which value uniquely identify that statement. Other nodes may refer +// by reference attributes to this value (currently used only for Label). +// +// TYPE_ATTRIBUTE_XML( FN ) - Type nodes refer to the result type id of an +// expression by a "type" attribute. FN is internally used by clang. +// +// ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally +// used by clang. A boolean attribute have the values "0" or "1". +// +// ATTRIBUTE_SPECIAL_XML( FN, NAME ) - An attribute named NAME which deserves +// a special handling. See the appropriate documentations. +// +// ATTRIBUTE_FILE_LOCATION_XML - A bunch of attributes denoting the location of +// a statement in the source file(s). +// +// ATTRIBUTE_OPT_XML( FN, NAME ) - An optional attribute named NAME. +// Optional attributes are omitted for boolean types, if the value is false, +// for integral types, if the value is null and for strings, +// if the value is the empty string. FN is internally used by clang. +// +// ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value +// is an enumeration defined with ENUM_XML macros immediately following after +// that macro. An optional attribute is ommited, if the particular enum is the +// empty string. FN is internally used by clang. +// +// ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is +// internally used by clang. +// +// END_ENUM_XML - Closes the enumeration definition of the current attribute. +// +// SUB_NODE_XML( CLASS ) - A mandatory sub-node of class CLASS or its sub-classes. +// +// SUB_NODE_OPT_XML( CLASS ) - An optional sub-node of class CLASS or its sub-classes. +// +// SUB_NODE_SEQUENCE_XML( CLASS ) - Zero or more sub-nodes of class CLASS or +// its sub-classes. +// +//===----------------------------------------------------------------------===// + +#ifndef ATTRIBUTE_FILE_LOCATION_XML +# define ATTRIBUTE_FILE_LOCATION_XML \ + ATTRIBUTE_XML(getFilename(), "file") \ + ATTRIBUTE_XML(getLine(), "line") \ + ATTRIBUTE_XML(getColumn(), "col") \ + ATTRIBUTE_OPT_XML(getFilename(), "endfile") \ + ATTRIBUTE_OPT_XML(getLine(), "endline") \ + ATTRIBUTE_OPT_XML(getColumn(), "endcol") +#endif + +#ifndef TYPE_ATTRIBUTE_XML +# define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type") +#endif + +#ifndef CONTEXT_ATTRIBUTE_XML +# 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 +END_NODE_XML + +NODE_XML(CompoundStmt, "CompoundStmt") + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(size(), "num_stmts") + SUB_NODE_SEQUENCE_XML(Stmt) +END_NODE_XML + +NODE_XML(CaseStmt, "CaseStmt") // case expr: body; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Stmt) // body + SUB_NODE_XML(Expr) // expr + SUB_NODE_XML(Expr) // rhs expr in gc extension: case expr .. expr: body; +END_NODE_XML + +NODE_XML(DefaultStmt, "DefaultStmt") // default: body; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Stmt) // body +END_NODE_XML + +NODE_XML(LabelStmt, "LabelStmt") // Label: body; + ID_ATTRIBUTE_XML + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getName(), "name") // string + SUB_NODE_XML(Stmt) // body +END_NODE_XML + +NODE_XML(IfStmt, "IfStmt") // if (cond) stmt1; else stmt2; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Expr) // cond + SUB_NODE_XML(Stmt) // stmt1 + SUB_NODE_XML(Stmt) // stmt2 +END_NODE_XML + +NODE_XML(SwitchStmt, "SwitchStmt") // switch (cond) body; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Expr) // cond + SUB_NODE_XML(Stmt) // body +END_NODE_XML + +NODE_XML(WhileStmt, "WhileStmt") // while (cond) body; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Expr) // cond + SUB_NODE_XML(Stmt) // body +END_NODE_XML + +NODE_XML(DoStmt, "DoStmt") // do body while (cond); + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Expr) // cond + SUB_NODE_XML(Stmt) // body +END_NODE_XML + +NODE_XML(ForStmt, "ForStmt") // for (init; cond; inc) body; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Stmt) // init + SUB_NODE_XML(Expr) // cond + SUB_NODE_XML(Expr) // inc + SUB_NODE_XML(Stmt) // body +END_NODE_XML + +NODE_XML(GotoStmt, "GotoStmt") // goto label; + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getLabel()->getName(), "name") // informal string + ATTRIBUTE_XML(getLabel(), "ref") // id string +END_NODE_XML + +NODE_XML(IndirectGotoStmt, "IndirectGotoStmt") // goto expr; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(ContinueStmt, "ContinueStmt") // continue + ATTRIBUTE_FILE_LOCATION_XML +END_NODE_XML + +NODE_XML(BreakStmt, "BreakStmt") // break + ATTRIBUTE_FILE_LOCATION_XML +END_NODE_XML + +NODE_XML(ReturnStmt, "ReturnStmt") // return expr; + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(AsmStmt, "AsmStmt") // GNU inline-assembly statement extension + ATTRIBUTE_FILE_LOCATION_XML + // FIXME +END_NODE_XML + +NODE_XML(DeclStmt, "DeclStmt") // a declaration statement + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_SEQUENCE_XML(Decl) +END_NODE_XML + +// C++ statements +NODE_XML(CXXTryStmt, "CXXTryStmt") // try CompoundStmt CXXCatchStmt1 CXXCatchStmt2 .. + ATTRIBUTE_FILE_LOCATION_XML + ATTRIBUTE_XML(getNumHandlers(), "num_handlers") + SUB_NODE_XML(CompoundStmt) + SUB_NODE_SEQUENCE_XML(CXXCatchStmt) +END_NODE_XML + +NODE_XML(CXXCatchStmt, "CXXCatchStmt") // catch (decl) Stmt + ATTRIBUTE_FILE_LOCATION_XML + SUB_NODE_XML(VarDecl) + SUB_NODE_XML(Stmt) +END_NODE_XML + +// Expressions +NODE_XML(PredefinedExpr, "PredefinedExpr") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_ENUM_XML(getIdentType(), "kind") + ENUM_XML(PredefinedExpr::Func, "__func__") + ENUM_XML(PredefinedExpr::Function, "__FUNCTION__") + ENUM_XML(PredefinedExpr::PrettyFunction, "__PRETTY_FUNCTION__") + END_ENUM_XML +END_NODE_XML + +NODE_XML(DeclRefExpr, "DeclRefExpr") // an expression referring to a declared entity + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getDecl(), "ref") // id string of the declaration + ATTRIBUTE_XML(getDecl()->getNameAsString(), "name") // informal + //ATTRIBUTE_ENUM_XML(getDecl()->getKind(), "kind") // really needed here? +END_NODE_XML + +NODE_XML(IntegerLiteral, "IntegerLiteral") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getValue(), "value") // (signed) integer +END_NODE_XML + +NODE_XML(CharacterLiteral, "CharacterLiteral") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getValue(), "value") // unsigned +END_NODE_XML + +NODE_XML(FloatingLiteral, "FloatingLiteral") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + // FIXME: output float as written in source (no approximation or the like) + //ATTRIBUTE_XML(getValueAsApproximateDouble(), "value") // float +END_NODE_XML + +NODE_XML(StringLiteral, "StringLiteral") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_SPECIAL_XML(getStrData(), "value") // string, special handling for escaping needed + ATTRIBUTE_OPT_XML(isWide(), "is_wide") // boolean +END_NODE_XML + +NODE_XML(UnaryOperator, "UnaryOperator") // op(expr) or (expr)op + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_ENUM_XML(getOpcode(), "kind") + ENUM_XML(UO_PostInc, "postinc") + ENUM_XML(UO_PostDec, "postdec") + ENUM_XML(UO_PreInc, "preinc") + ENUM_XML(UO_PreDec, "predec") + ENUM_XML(UO_AddrOf, "addrof") + ENUM_XML(UO_Deref, "deref") + ENUM_XML(UO_Plus, "plus") + ENUM_XML(UO_Minus, "minus") + ENUM_XML(UO_Not, "not") // bitwise not + ENUM_XML(UO_LNot, "lnot") // boolean not + ENUM_XML(UO_Real, "__real") + ENUM_XML(UO_Imag, "__imag") + ENUM_XML(UO_Extension, "__extension__") + END_ENUM_XML + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(BinaryOperator, "BinaryOperator") // (expr1) op (expr2) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_ENUM_XML(getOpcode(), "kind") + ENUM_XML(BO_PtrMemD , "ptrmemd") + ENUM_XML(BO_PtrMemI , "ptrmemi") + ENUM_XML(BO_Mul , "mul") + ENUM_XML(BO_Div , "div") + ENUM_XML(BO_Rem , "rem") + ENUM_XML(BO_Add , "add") + ENUM_XML(BO_Sub , "sub") + ENUM_XML(BO_Shl , "shl") + ENUM_XML(BO_Shr , "shr") + ENUM_XML(BO_LT , "lt") + ENUM_XML(BO_GT , "gt") + ENUM_XML(BO_LE , "le") + ENUM_XML(BO_GE , "ge") + ENUM_XML(BO_EQ , "eq") + ENUM_XML(BO_NE , "ne") + ENUM_XML(BO_And , "and") // bitwise and + ENUM_XML(BO_Xor , "xor") + ENUM_XML(BO_Or , "or") // bitwise or + ENUM_XML(BO_LAnd , "land") // boolean and + ENUM_XML(BO_LOr , "lor") // boolean or + ENUM_XML(BO_Assign , "assign") + ENUM_XML(BO_MulAssign, "mulassign") + ENUM_XML(BO_DivAssign, "divassign") + ENUM_XML(BO_RemAssign, "remassign") + ENUM_XML(BO_AddAssign, "addassign") + ENUM_XML(BO_SubAssign, "subassign") + ENUM_XML(BO_ShlAssign, "shlassign") + ENUM_XML(BO_ShrAssign, "shrassign") + ENUM_XML(BO_AndAssign, "andassign") + ENUM_XML(BO_XorAssign, "xorassign") + ENUM_XML(BO_OrAssign , "orassign") + ENUM_XML(BO_Comma , "comma") + END_ENUM_XML + SUB_NODE_XML(Expr) // expr1 + SUB_NODE_XML(Expr) // expr2 +END_NODE_XML + +// FIXME: is there a special class needed or is BinaryOperator sufficient? +//NODE_XML(CompoundAssignOperator, "CompoundAssignOperator") + +NODE_XML(ConditionalOperator, "ConditionalOperator") // expr1 ? expr2 : expr3 + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) // expr1 + SUB_NODE_XML(Expr) // expr2 + SUB_NODE_XML(Expr) // expr3 +END_NODE_XML + +NODE_XML(OffsetOfExpr, "OffsetOfExpr") // offsetof(basetype, components) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getTypeSourceInfo()->getType()) + ATTRIBUTE_XML(getNumComponents(), "num_components") + SUB_NODE_SEQUENCE_XML(OffsetOfExpr::OffsetOfNode) +END_NODE_XML + +NODE_XML(SizeOfAlignOfExpr, "SizeOfAlignOfExpr") // sizeof(expr) or alignof(expr) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(isSizeOf(), "is_sizeof") + ATTRIBUTE_XML(isArgumentType(), "is_type") // "1" if expr denotes a type + ATTRIBUTE_SPECIAL_XML(getArgumentType(), "type_ref") // optional, denotes the type of expr, if is_type=="1", special handling needed since getArgumentType() could assert + SUB_NODE_OPT_XML(Expr) // expr, if is_type=="0" +END_NODE_XML + +NODE_XML(ArraySubscriptExpr, "ArraySubscriptExpr") // expr1[expr2] + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) // expr1 + SUB_NODE_XML(Expr) // expr2 +END_NODE_XML + +NODE_XML(CallExpr, "CallExpr") // fnexpr(arg1, arg2, ...) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getNumArgs(), "num_args") // unsigned + SUB_NODE_XML(Expr) // fnexpr + SUB_NODE_SEQUENCE_XML(Expr) // arg1..argN +END_NODE_XML + +NODE_XML(MemberExpr, "MemberExpr") // expr->F or expr.F + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(isArrow(), "is_deref") + ATTRIBUTE_XML(getMemberDecl(), "ref") // refers to F + ATTRIBUTE_XML(getMemberDecl()->getNameAsString(), "name") // informal + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(CStyleCastExpr, "CStyleCastExpr") // (type)expr + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getTypeAsWritten(), "type_ref") // denotes the type as written in the source code + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(ImplicitCastExpr, "ImplicitCastExpr") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) +END_NODE_XML + +NODE_XML(CompoundLiteralExpr, "CompoundLiteralExpr") // [C99 6.5.2.5] + SUB_NODE_XML(Expr) // init +END_NODE_XML + +NODE_XML(ExtVectorElementExpr, "ExtVectorElementExpr") + SUB_NODE_XML(Expr) // base +END_NODE_XML + +NODE_XML(InitListExpr, "InitListExpr") // struct foo x = { expr1, { expr2, expr3 } }; + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_OPT_XML(getInitializedFieldInUnion(), "field_ref") // if a union is initialized, this refers to the initialized union field id + ATTRIBUTE_XML(getNumInits(), "num_inits") // unsigned + SUB_NODE_SEQUENCE_XML(Expr) // expr1..exprN +END_NODE_XML + +NODE_XML(DesignatedInitExpr, "DesignatedInitExpr") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) +END_NODE_XML + +NODE_XML(ImplicitValueInitExpr, "ImplicitValueInitExpr") // Implicit value initializations occur within InitListExpr + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) +END_NODE_XML + +NODE_XML(VAArgExpr, "VAArgExpr") // used for the builtin function __builtin_va_start(expr) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(ParenExpr, "ParenExpr") // this represents a parethesized expression "(expr)". Only formed if full location information is requested. + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +// GNU Extensions +NODE_XML(AddrLabelExpr, "AddrLabelExpr") // the GNU address of label extension, representing &&label. + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getLabel(), "ref") // id string + SUB_NODE_XML(LabelStmt) // expr +END_NODE_XML + +NODE_XML(StmtExpr, "StmtExpr") // StmtExpr contains a single CompoundStmt node, which it evaluates and takes the value of the last subexpression. + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(CompoundStmt) +END_NODE_XML + +NODE_XML(ChooseExpr, "ChooseExpr") // GNU builtin-in function __builtin_choose_expr(expr1, expr2, expr3) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) // expr1 + SUB_NODE_XML(Expr) // expr2 + SUB_NODE_XML(Expr) // expr3 +END_NODE_XML + +NODE_XML(GNUNullExpr, "GNUNullExpr") // GNU __null extension + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) +END_NODE_XML + +// C++ Expressions +NODE_XML(CXXOperatorCallExpr, "CXXOperatorCallExpr") // fnexpr(arg1, arg2, ...) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getNumArgs(), "num_args") // unsigned + SUB_NODE_XML(Expr) // fnexpr + SUB_NODE_SEQUENCE_XML(Expr) // arg1..argN +END_NODE_XML + +NODE_XML(CXXConstructExpr, "CXXConstructExpr") // ctor(arg1, arg2, ...) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getNumArgs(), "num_args") // unsigned + SUB_NODE_XML(Expr) // fnexpr + SUB_NODE_SEQUENCE_XML(Expr) // arg1..argN +END_NODE_XML + +NODE_XML(CXXNamedCastExpr, "CXXNamedCastExpr") // xxx_cast<type>(expr) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_ENUM_XML(getStmtClass(), "kind") + ENUM_XML(Stmt::CXXStaticCastExprClass, "static_cast") + ENUM_XML(Stmt::CXXDynamicCastExprClass, "dynamic_cast") + ENUM_XML(Stmt::CXXReinterpretCastExprClass, "reinterpret_cast") + ENUM_XML(Stmt::CXXConstCastExprClass, "const_cast") + END_ENUM_XML + ATTRIBUTE_XML(getTypeAsWritten(), "type_ref") // denotes the type as written in the source code + SUB_NODE_XML(Expr) // expr +END_NODE_XML + +NODE_XML(CXXMemberCallExpr, "CXXMemberCallExpr") // fnexpr(arg1, arg2, ...) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getNumArgs(), "num_args") // unsigned + SUB_NODE_XML(Expr) // fnexpr + SUB_NODE_SEQUENCE_XML(Expr) // arg1..argN +END_NODE_XML + +NODE_XML(CXXBoolLiteralExpr, "CXXBoolLiteralExpr") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getValue(), "value") // boolean +END_NODE_XML + +NODE_XML(CXXNullPtrLiteralExpr, "CXXNullPtrLiteralExpr") // [C++0x 2.14.7] C++ Pointer Literal + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) +END_NODE_XML + +NODE_XML(CXXTypeidExpr, "CXXTypeidExpr") // typeid(expr) + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(isTypeOperand(), "is_type") // "1" if expr denotes a type + ATTRIBUTE_SPECIAL_XML(getTypeOperand(), "type_ref") // optional, denotes the type of expr, if is_type=="1", special handling needed since getTypeOperand() could assert + SUB_NODE_OPT_XML(Expr) // expr, if is_type=="0" +END_NODE_XML + +NODE_XML(CXXThisExpr, "CXXThisExpr") // this + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) +END_NODE_XML + +NODE_XML(CXXThrowExpr, "CXXThrowExpr") // throw (expr); + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + SUB_NODE_XML(Expr) // NULL in case of "throw;" +END_NODE_XML + +NODE_XML(CXXDefaultArgExpr, "CXXDefaultArgExpr") + ATTRIBUTE_FILE_LOCATION_XML + TYPE_ATTRIBUTE_XML(getType()) + ATTRIBUTE_XML(getParam(), "ref") // id of the parameter declaration (the expression is a subnode of the declaration) +END_NODE_XML + +//===----------------------------------------------------------------------===// +#undef NODE_XML +#undef ID_ATTRIBUTE_XML +#undef TYPE_ATTRIBUTE_XML +#undef ATTRIBUTE_XML +#undef ATTRIBUTE_SPECIAL_XML +#undef ATTRIBUTE_OPT_XML +#undef ATTRIBUTE_ENUM_XML +#undef ATTRIBUTE_ENUM_OPT_XML +#undef ATTRIBUTE_FILE_LOCATION_XML +#undef ENUM_XML +#undef END_ENUM_XML +#undef END_NODE_XML +#undef SUB_NODE_XML +#undef SUB_NODE_SEQUENCE_XML +#undef SUB_NODE_OPT_XML diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h new file mode 100644 index 0000000..380a1dd --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h @@ -0,0 +1,52 @@ +//===--- TextDiagnosticBuffer.h - Buffer Text Diagnostics -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is a concrete diagnostic client, which buffers the diagnostic messages. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_BUFFER_H_ +#define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_BUFFER_H_ + +#include "clang/Basic/Diagnostic.h" +#include <vector> + +namespace clang { + +class Preprocessor; +class SourceManager; + +class TextDiagnosticBuffer : public DiagnosticClient { +public: + typedef std::vector<std::pair<SourceLocation, std::string> > DiagList; + typedef DiagList::iterator iterator; + typedef DiagList::const_iterator const_iterator; +private: + DiagList Errors, Warnings, Notes; +public: + const_iterator err_begin() const { return Errors.begin(); } + const_iterator err_end() const { return Errors.end(); } + + const_iterator warn_begin() const { return Warnings.begin(); } + const_iterator warn_end() const { return Warnings.end(); } + + const_iterator note_begin() const { return Notes.begin(); } + const_iterator note_end() const { return Notes.end(); } + + virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, + const DiagnosticInfo &Info); + + /// FlushDiagnostics - Flush the buffered diagnostics to an given + /// diagnostic engine. + void FlushDiagnostics(Diagnostic &Diags) const; +}; + +} // end namspace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h new file mode 100644 index 0000000..f530294 --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h @@ -0,0 +1,80 @@ +//===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is a concrete diagnostic client, which prints the diagnostics to +// standard error. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_ +#define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_ + +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/SourceLocation.h" + +namespace clang { +class DiagnosticOptions; +class LangOptions; + +class TextDiagnosticPrinter : public DiagnosticClient { + llvm::raw_ostream &OS; + const LangOptions *LangOpts; + const DiagnosticOptions *DiagOpts; + + SourceLocation LastWarningLoc; + FullSourceLoc LastLoc; + unsigned LastCaretDiagnosticWasNote : 1; + unsigned OwnsOutputStream : 1; + + /// A string to prefix to error messages. + std::string Prefix; + +public: + TextDiagnosticPrinter(llvm::raw_ostream &os, const DiagnosticOptions &diags, + bool OwnsOutputStream = false); + virtual ~TextDiagnosticPrinter(); + + /// setPrefix - Set the diagnostic printer prefix string, which will be + /// printed at the start of any diagnostics. If empty, no prefix string is + /// used. + void setPrefix(std::string Value) { Prefix = Value; } + + void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) { + LangOpts = &LO; + } + + void EndSourceFile() { + LangOpts = 0; + } + + void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM); + + void HighlightRange(const CharSourceRange &R, + const SourceManager &SrcMgr, + unsigned LineNo, FileID FID, + std::string &CaretLine, + const std::string &SourceLine); + + void EmitCaretDiagnostic(SourceLocation Loc, + CharSourceRange *Ranges, unsigned NumRanges, + const SourceManager &SM, + const FixItHint *Hints, + unsigned NumHints, + unsigned Columns, + unsigned OnMacroInst, + unsigned MacroSkipStart, + unsigned MacroSkipEnd); + + virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, + const DiagnosticInfo &Info); +}; + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TypeXML.def b/contrib/llvm/tools/clang/include/clang/Frontend/TypeXML.def new file mode 100644 index 0000000..b78e70f --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TypeXML.def @@ -0,0 +1,304 @@ +//===-- TypeXML.def - Metadata about Type XML nodes ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the XML type info database as written in the +// <ReferenceSection>/<Types> sub-nodes of the XML document. Type nodes +// are referred by "type" reference attributes throughout the document. +// A type node never contains sub-nodes. +// The semantics of the attributes and enums are mostly self-documenting +// by looking at the appropriate internally used functions and values. +// The following macros are used: +// +// NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete +// type of class CLASS where CLASS is a class name used internally by clang. +// After a NODE_XML the definition of all (optional) attributes of that type +// node follows. +// +// END_NODE_XML - Closes the attribute definition of the current node. +// +// ID_ATTRIBUTE_XML - Each type node has an "id" attribute containing a +// string, which value uniquely identify the type. Other nodes may refer +// by "type" reference attributes to this value. +// +// TYPE_ATTRIBUTE_XML( FN ) - Type nodes may refer to the ids of other type +// nodes by a "type" attribute. FN is internally used by clang. +// +// CONTEXT_ATTRIBUTE_XML( FN ) - Type nodes may refer to the ids of their +// declaration contexts by a "context" attribute. FN is internally used by +// clang. +// +// ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally +// used by clang. A boolean attribute have the values "0" or "1". +// +// ATTRIBUTE_OPT_XML( FN, NAME ) - An optional attribute named NAME. +// Optional attributes are omitted for boolean types, if the value is false, +// for integral types, if the value is null and for strings, +// if the value is the empty string. FN is internally used by clang. +// +// ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value +// is an enumeration defined with ENUM_XML macros immediately following after +// that macro. An optional attribute is ommited, if the particular enum is the +// empty string. FN is internally used by clang. +// +// ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is +// internally used by clang. +// +// END_ENUM_XML - Closes the enumeration definition of the current attribute. +// +//===----------------------------------------------------------------------===// + +#ifndef TYPE_ATTRIBUTE_XML +# define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type") +#endif + +#ifndef CONTEXT_ATTRIBUTE_XML +# define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context") +#endif + +NODE_XML(Type, "FIXME_Type") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getTypeClassName(), "unhandled_type_name") +END_NODE_XML + +NODE_XML(QualType, "CvQualifiedType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getTypePtr()) // the qualified type, e.g. for 'T* const' it's 'T*' + ATTRIBUTE_OPT_XML(isLocalConstQualified(), "const") // boolean + ATTRIBUTE_OPT_XML(isLocalVolatileQualified(), "volatile") // boolean + ATTRIBUTE_OPT_XML(isLocalRestrictQualified(), "restrict") // boolean + ATTRIBUTE_OPT_XML(getObjCGCAttr(), "objc_gc") // Qualifiers::GC + ATTRIBUTE_OPT_XML(getAddressSpace(), "address_space") // unsigned +END_NODE_XML + +NODE_XML(BuiltinType, "FundamentalType") + ID_ATTRIBUTE_XML + ATTRIBUTE_ENUM_XML(getKind(), "kind") + ENUM_XML(BuiltinType::Void, "void") + ENUM_XML(BuiltinType::Bool, "bool") + ENUM_XML(BuiltinType::Char_U, "char") // not explicitely qualified char, depends on target platform + ENUM_XML(BuiltinType::Char_S, "char") // not explicitely qualified char, depends on target platform + ENUM_XML(BuiltinType::SChar, "signed char") + ENUM_XML(BuiltinType::Short, "short"); + ENUM_XML(BuiltinType::Int, "int"); + ENUM_XML(BuiltinType::Long, "long"); + ENUM_XML(BuiltinType::LongLong, "long long"); + ENUM_XML(BuiltinType::Int128, "__int128_t"); + ENUM_XML(BuiltinType::UChar, "unsigned char"); + ENUM_XML(BuiltinType::UShort, "unsigned short"); + ENUM_XML(BuiltinType::UInt, "unsigned int"); + ENUM_XML(BuiltinType::ULong, "unsigned long"); + ENUM_XML(BuiltinType::ULongLong, "unsigned long long"); + ENUM_XML(BuiltinType::UInt128, "__uint128_t"); + ENUM_XML(BuiltinType::Float, "float"); + ENUM_XML(BuiltinType::Double, "double"); + ENUM_XML(BuiltinType::LongDouble, "long double"); + ENUM_XML(BuiltinType::WChar_U, "wchar_t"); + ENUM_XML(BuiltinType::WChar_S, "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"); + END_ENUM_XML +END_NODE_XML + +NODE_XML(PointerType, "PointerType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getPointeeType()) +END_NODE_XML + +NODE_XML(LValueReferenceType, "ReferenceType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getPointeeType()) +END_NODE_XML + +NODE_XML(RValueReferenceType, "ReferenceType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getPointeeType()) +END_NODE_XML + +NODE_XML(FunctionNoProtoType, "FunctionNoProtoType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(FunctionProtoType, "FunctionType") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getResultType(), "result_type") + ATTRIBUTE_OPT_XML(isVariadic(), "variadic") + ATTRIBUTE_ENUM_XML(getCallConv(), "call_conv") + ENUM_XML(CC_Default, "") + ENUM_XML(CC_C, "C") + ENUM_XML(CC_X86StdCall, "X86StdCall") + ENUM_XML(CC_X86FastCall, "X86FastCall") + ENUM_XML(CC_X86ThisCall, "X86ThisCall") + END_ENUM_XML +END_NODE_XML + +NODE_XML(TypedefType, "Typedef") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getDecl()->getUnderlyingType()) + ATTRIBUTE_XML(getDecl()->getNameAsString(), "name") // string + CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext()) +END_NODE_XML + +NODE_XML(ComplexType, "ComplexType") // C99 complex types (_Complex float etc) + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) +END_NODE_XML + +NODE_XML(BlockPointerType, "BlockPointerType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getPointeeType()) // alway refers to a function type +END_NODE_XML + +NODE_XML(MemberPointerType, "MemberPointerType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getPointeeType()) + ATTRIBUTE_XML(getClass(), "class_type") // refers to the class type id of which the pointee is a member +END_NODE_XML + +NODE_XML(ConstantArrayType, "ArrayType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) + ATTRIBUTE_XML(getSize(), "size") // unsigned + ATTRIBUTE_ENUM_OPT_XML(getSizeModifier(), "size_modifier") + ENUM_XML(ArrayType::Normal, "") + ENUM_XML(ArrayType::Static, "static") + ENUM_XML(ArrayType::Star, "star") + END_ENUM_XML + ATTRIBUTE_OPT_XML(getIndexTypeCVRQualifiers(), "index_type_qualifier") // unsigned +END_NODE_XML + +NODE_XML(IncompleteArrayType, "IncompleteArrayType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) +END_NODE_XML + +NODE_XML(VariableArrayType, "VariableArrayType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) + // note: the size expression is print at the point of declaration +END_NODE_XML + +NODE_XML(DependentSizedArrayType, "DependentSizedArrayType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) + // FIXME: how to deal with size expression? +END_NODE_XML + +NODE_XML(VectorType, "VectorType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) + ATTRIBUTE_XML(getNumElements(), "size") // unsigned +END_NODE_XML + +NODE_XML(ExtVectorType, "ExtVectorType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getElementType()) + ATTRIBUTE_XML(getNumElements(), "size") // unsigned +END_NODE_XML + +NODE_XML(TypeOfExprType, "TypeOfExprType") + ID_ATTRIBUTE_XML + // note: the typeof expression is print at the point of use +END_NODE_XML + +NODE_XML(TypeOfType, "TypeOfType") + ID_ATTRIBUTE_XML + TYPE_ATTRIBUTE_XML(getUnderlyingType()) +END_NODE_XML + + +NODE_XML(RecordType, "Record") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDecl()->getNameAsString(), "name") // string + ATTRIBUTE_ENUM_XML(getDecl()->getTagKind(), "kind") + ENUM_XML(TTK_Struct, "struct") + ENUM_XML(TTK_Union, "union") + ENUM_XML(TTK_Class, "class") + END_ENUM_XML + CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext()) +END_NODE_XML + +NODE_XML(EnumType, "Enum") + ID_ATTRIBUTE_XML + ATTRIBUTE_XML(getDecl()->getNameAsString(), "name") // string + CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext()) +END_NODE_XML + +NODE_XML(TemplateTypeParmType, "TemplateTypeParmType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(TemplateSpecializationType, "TemplateSpecializationType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(ElaboratedType, "ElaboratedType") + ID_ATTRIBUTE_XML + ATTRIBUTE_ENUM_XML(getKeyword(), "keyword") + ENUM_XML(ETK_None, "none") + ENUM_XML(ETK_Typename, "typename") + ENUM_XML(ETK_Struct, "struct") + ENUM_XML(ETK_Union, "union") + ENUM_XML(ETK_Class, "class") + ENUM_XML(ETK_Enum, "enum") + END_ENUM_XML + TYPE_ATTRIBUTE_XML(getNamedType()) +END_NODE_XML + +NODE_XML(InjectedClassNameType, "InjectedClassNameType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(DependentNameType, "DependentNameType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(DependentTemplateSpecializationType, + "DependentTemplateSpecializationType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(ObjCInterfaceType, "ObjCInterfaceType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(ObjCObjectPointerType, "ObjCObjectPointerType") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(SubstTemplateTypeParmType, "SubstTemplateTypeParm") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(DependentSizedExtVectorType, "DependentSizedExtVector") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(UnresolvedUsingType, "UnresolvedUsing") + ID_ATTRIBUTE_XML +END_NODE_XML + +NODE_XML(DecltypeType, "Decltype") + ID_ATTRIBUTE_XML +END_NODE_XML + +//===----------------------------------------------------------------------===// +#undef NODE_XML +#undef ID_ATTRIBUTE_XML +#undef TYPE_ATTRIBUTE_XML +#undef CONTEXT_ATTRIBUTE_XML +#undef ATTRIBUTE_XML +#undef ATTRIBUTE_OPT_XML +#undef ATTRIBUTE_ENUM_XML +#undef ATTRIBUTE_ENUM_OPT_XML +#undef ENUM_XML +#undef END_ENUM_XML +#undef END_NODE_XML diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h new file mode 100644 index 0000000..485161b --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h @@ -0,0 +1,94 @@ +//===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This header contains miscellaneous utilities for various front-end actions. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_UTILS_H +#define LLVM_CLANG_FRONTEND_UTILS_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { +class Triple; +} + +namespace clang { +class ASTConsumer; +class CompilerInstance; +class Decl; +class DependencyOutputOptions; +class Diagnostic; +class DiagnosticOptions; +class HeaderSearch; +class HeaderSearchOptions; +class IdentifierTable; +class LangOptions; +class Preprocessor; +class PreprocessorOptions; +class PreprocessorOutputOptions; +class SourceManager; +class Stmt; +class TargetInfo; +class FrontendOptions; + +/// Normalize \arg File for use in a user defined #include directive (in the +/// predefines buffer). +std::string NormalizeDashIncludePath(llvm::StringRef File); + +/// Apply the header search options to get given HeaderSearch object. +void ApplyHeaderSearchOptions(HeaderSearch &HS, + const HeaderSearchOptions &HSOpts, + const LangOptions &Lang, + const llvm::Triple &triple); + +/// InitializePreprocessor - Initialize the preprocessor getting it and the +/// environment ready to process a single file. +void InitializePreprocessor(Preprocessor &PP, + const PreprocessorOptions &PPOpts, + const HeaderSearchOptions &HSOpts, + const FrontendOptions &FEOpts); + +/// ProcessWarningOptions - Initialize the diagnostic client and process the +/// warning options specified on the command line. +void ProcessWarningOptions(Diagnostic &Diags, const DiagnosticOptions &Opts); + +/// DoPrintPreprocessedInput - Implement -E mode. +void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS, + const PreprocessorOutputOptions &Opts); + +/// CheckDiagnostics - Gather the expected diagnostics and check them. +bool CheckDiagnostics(Preprocessor &PP); + +/// AttachDependencyFileGen - Create a dependency file generator, and attach +/// it to the given preprocessor. This takes ownership of the output stream. +void AttachDependencyFileGen(Preprocessor &PP, + const DependencyOutputOptions &Opts); + +/// AttachHeaderIncludeGen - Create a header include list generator, and attach +/// it to the given preprocessor. +/// +/// \param ShowAllHeaders - If true, show all header information instead of just +/// headers following the predefines buffer. This is useful for making sure +/// includes mentioned on the command line are also reported, but differs from +/// the default behavior used by -H. +/// \param OutputPath - If non-empty, a path to write the header include +/// information to, instead of writing to stderr. +void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false, + llvm::StringRef OutputPath = ""); + +/// CacheTokens - Cache tokens for use with PCH. Note that this requires +/// a seekable stream. +void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); + +} // end namespace clang + +#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticsClient.h b/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticsClient.h new file mode 100644 index 0000000..793cedd --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticsClient.h @@ -0,0 +1,94 @@ +//===-- VerifyDiagnosticsClient.h - Verifying Diagnostic Client -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICSCLIENT_H +#define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICSCLIENT_H + +#include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/OwningPtr.h" + +namespace clang { + +class Diagnostic; +class TextDiagnosticBuffer; + +/// VerifyDiagnosticsClient - Create a diagnostic client which will use markers +/// in the input source to check that all the emitted diagnostics match those +/// expected. +/// +/// USING THE DIAGNOSTIC CHECKER: +/// +/// Indicating that a line expects an error or a warning is simple. Put a +/// comment on the line that has the diagnostic, use: +/// +/// expected-{error,warning,note} +/// +/// to tag if it's an expected error or warning, and place the expected text +/// between {{ and }} markers. The full text doesn't have to be included, only +/// enough to ensure that the correct diagnostic was emitted. +/// +/// Here's an example: +/// +/// int A = B; // expected-error {{use of undeclared identifier 'B'}} +/// +/// You can place as many diagnostics on one line as you wish. To make the code +/// more readable, you can use slash-newline to separate out the diagnostics. +/// +/// The simple syntax above allows each specification to match exactly one +/// error. You can use the extended syntax to customize this. The extended +/// syntax is "expected-<type> <n> {{diag text}}", where <type> is one of +/// "error", "warning" or "note", and <n> is a positive integer. This allows the +/// diagnostic to appear as many times as specified. Example: +/// +/// void f(); // expected-note 2 {{previous declaration is here}} +/// +/// Regex matching mode may be selected by appending '-re' to type. Example: +/// +/// expected-error-re +/// +/// Examples matching error: "variable has incomplete type 'struct s'" +/// +/// // expected-error {{variable has incomplete type 'struct s'}} +/// // expected-error {{variable has incomplete type}} +/// +/// // expected-error-re {{variable has has type 'struct .'}} +/// // expected-error-re {{variable has has type 'struct .*'}} +/// // expected-error-re {{variable has has type 'struct (.*)'}} +/// // expected-error-re {{variable has has type 'struct[[:space:]](.*)'}} +/// +class VerifyDiagnosticsClient : public DiagnosticClient { +public: + Diagnostic &Diags; + llvm::OwningPtr<DiagnosticClient> PrimaryClient; + llvm::OwningPtr<TextDiagnosticBuffer> Buffer; + Preprocessor *CurrentPreprocessor; + +private: + void CheckDiagnostics(); + +public: + /// Create a new verifying diagnostic client, which will issue errors to \arg + /// PrimaryClient when a diagnostic does not match what is expected (as + /// indicated in the source file). The verifying diagnostic client takes + /// ownership of \arg PrimaryClient. + VerifyDiagnosticsClient(Diagnostic &Diags, DiagnosticClient *PrimaryClient); + ~VerifyDiagnosticsClient(); + + virtual void BeginSourceFile(const LangOptions &LangOpts, + const Preprocessor *PP); + + virtual void EndSourceFile(); + + virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, + const DiagnosticInfo &Info); +}; + +} // end namspace clang + +#endif |