diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Frontend')
23 files changed, 470 insertions, 327 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h b/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h index 3c05834..cef9509 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ASTConsumers.h @@ -14,15 +14,16 @@ #ifndef DRIVER_ASTCONSUMERS_H #define DRIVER_ASTCONSUMERS_H +#include "clang/Basic/LLVM.h" + namespace llvm { - class raw_ostream; namespace sys { class Path; } } namespace clang { class ASTConsumer; class CodeGenOptions; -class Diagnostic; +class DiagnosticsEngine; class FileManager; class LangOptions; class Preprocessor; @@ -32,7 +33,7 @@ class TargetOptions; // original C code. The output is intended to be in a format such that // clang could re-parse the output back into the same AST, but the // implementation is still incomplete. -ASTConsumer *CreateASTPrinter(llvm::raw_ostream *OS); +ASTConsumer *CreateASTPrinter(raw_ostream *OS); // AST dumper: dumps the raw AST in human-readable form to stderr; this is // intended for debugging. @@ -40,7 +41,7 @@ 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); +ASTConsumer *CreateASTDumperXML(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 diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h index 58a60a1..471476a 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h @@ -18,6 +18,7 @@ #include "clang/Serialization/ASTBitCodes.h" #include "clang/Sema/Sema.h" #include "clang/Sema/CodeCompleteConsumer.h" +#include "clang/Lex/ModuleLoader.h" #include "clang/Lex/PreprocessingRecord.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/FileManager.h" @@ -41,10 +42,11 @@ namespace llvm { namespace clang { class ASTContext; +class ASTReader; class CodeCompleteConsumer; class CompilerInvocation; class Decl; -class Diagnostic; +class DiagnosticsEngine; class FileEntry; class FileManager; class HeaderSearch; @@ -65,19 +67,15 @@ class GlobalCodeCompletionAllocator /// \brief Utility class for loading a ASTContext from an AST file. /// -class ASTUnit { -public: - typedef std::map<FileID, std::vector<PreprocessedEntity *> > - PreprocessedEntitiesByFileMap; - +class ASTUnit : public ModuleLoader { private: - llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; - llvm::IntrusiveRefCntPtr<FileManager> FileMgr; - llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr; - llvm::OwningPtr<HeaderSearch> HeaderInfo; - llvm::IntrusiveRefCntPtr<TargetInfo> Target; - llvm::IntrusiveRefCntPtr<Preprocessor> PP; - llvm::IntrusiveRefCntPtr<ASTContext> Ctx; + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; + llvm::IntrusiveRefCntPtr<FileManager> FileMgr; + llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr; + llvm::OwningPtr<HeaderSearch> HeaderInfo; + llvm::IntrusiveRefCntPtr<TargetInfo> Target; + llvm::IntrusiveRefCntPtr<Preprocessor> PP; + llvm::IntrusiveRefCntPtr<ASTContext> Ctx; FileSystemOptions FileSystemOpts; @@ -111,8 +109,8 @@ private: /// \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 What kind of translation unit this AST represents. + TranslationUnitKind TUKind; /// \brief Whether we should time each operation. bool WantTiming; @@ -128,14 +126,6 @@ private: // 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; @@ -143,9 +133,12 @@ private: // Critical optimization when using clang_getCursor(). ASTLocation LastLoc; + /// \brief The set of diagnostics produced when creating the preamble. + SmallVector<StoredDiagnostic, 4> PreambleDiagnostics; + /// \brief The set of diagnostics produced when creating this /// translation unit. - llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics; + SmallVector<StoredDiagnostic, 4> StoredDiagnostics; /// \brief The number of stored diagnostics that come from the driver /// itself. @@ -156,27 +149,8 @@ private: /// \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; + SmallVector<llvm::sys::Path, 4> TemporaryFiles; - /// \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. /// @@ -191,9 +165,53 @@ private: /// \brief The file in which the precompiled preamble is stored. std::string PreambleFile; +public: + class PreambleData { + const FileEntry *File; + std::vector<char> Buffer; + mutable unsigned NumLines; + + public: + PreambleData() : File(0), NumLines(0) { } + + void assign(const FileEntry *F, const char *begin, const char *end) { + File = F; + Buffer.assign(begin, end); + NumLines = 0; + } + + void clear() { Buffer.clear(); File = 0; NumLines = 0; } + + size_t size() const { return Buffer.size(); } + bool empty() const { return Buffer.empty(); } + + const char *getBufferStart() const { return &Buffer[0]; } + + unsigned getNumLines() const { + if (NumLines) + return NumLines; + countLines(); + return NumLines; + } + + SourceRange getSourceRange(const SourceManager &SM) const { + SourceLocation FileLoc = SM.getLocForStartOfFile(SM.getPreambleFileID()); + return SourceRange(FileLoc, FileLoc.getLocWithOffset(size()-1)); + } + + private: + void countLines() const; + }; + + const PreambleData &getPreambleData() const { + return Preamble; + } + +private: + /// \brief The contents of the preamble that has been precompiled to /// \c PreambleFile. - std::vector<char> Preamble; + PreambleData Preamble; /// \brief Whether the preamble ends at the start of a new line. /// @@ -224,27 +242,15 @@ private: /// \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 + /// This value will be used to restore the state of the \c DiagnosticsEngine + /// 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; @@ -252,11 +258,19 @@ private: /// \brief Whether we want to include nested macro expansions in the /// detailed preprocessing record. bool NestedMacroExpansions; - - static void ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags, + + /// \brief The language options used when we load an AST file. + LangOptions ASTFileLangOpts; + + static void ConfigureDiags(llvm::IntrusiveRefCntPtr<DiagnosticsEngine> &Diags, const char **ArgBegin, const char **ArgEnd, ASTUnit &AST, bool CaptureDiagnostics); + void TranslateStoredDiagnostics(ASTReader *MMan, StringRef ModName, + SourceManager &SrcMan, + const SmallVectorImpl<StoredDiagnostic> &Diags, + SmallVectorImpl<StoredDiagnostic> &Out); + public: /// \brief A cached code-completion result, which may be introduced in one of /// many different contexts. @@ -309,10 +323,24 @@ public: return CachedCompletionAllocator; } + /// \brief Retrieve the allocator used to cache global code completions. + /// Creates the allocator if it doesn't already exist. + llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + getCursorCompletionAllocator() { + if (!CursorCompletionAllocator.getPtr()) { + CursorCompletionAllocator = new GlobalCodeCompletionAllocator; + } + return CursorCompletionAllocator; + } + private: /// \brief Allocator used to store cached code completions. llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> CachedCompletionAllocator; + + /// \brief Allocator used to store code completions for arbitrary cursors. + llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + CursorCompletionAllocator; /// \brief The set of cached code-completion results. std::vector<CachedCodeCompletionResult> CachedCompletionResults; @@ -367,23 +395,38 @@ private: bool AllowRebuild = true, unsigned MaxLines = 0); void RealizeTopLevelDeclsFromPreamble(); - void RealizePreprocessedEntitiesFromPreamble(); + /// \brief Allows 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. + /// Becomes a noop in release mode; only useful for debug mode checking. + class ConcurrencyState { + void *Mutex; // a llvm::sys::MutexImpl in debug; + + public: + ConcurrencyState(); + ~ConcurrencyState(); + + void start(); + void finish(); + }; + ConcurrencyState ConcurrencyCheckValue; + public: class ConcurrencyCheck { - volatile ASTUnit &Self; + ASTUnit &Self; public: explicit ConcurrencyCheck(ASTUnit &Self) : Self(Self) { - assert(Self.ConcurrencyCheckValue == CheckUnlocked && - "Concurrent access to ASTUnit!"); - Self.ConcurrencyCheckValue = CheckLocked; + Self.ConcurrencyCheckValue.start(); } - ~ConcurrencyCheck() { - Self.ConcurrencyCheckValue = CheckUnlocked; + Self.ConcurrencyCheckValue.finish(); } }; friend class ConcurrencyCheck; @@ -395,8 +438,8 @@ public: bool isUnsafeToFree() const { return UnsafeToFree; } void setUnsafeToFree(bool Value) { UnsafeToFree = Value; } - const Diagnostic &getDiagnostics() const { return *Diagnostics; } - Diagnostic &getDiagnostics() { return *Diagnostics; } + const DiagnosticsEngine &getDiagnostics() const { return *Diagnostics; } + DiagnosticsEngine &getDiagnostics() { return *Diagnostics; } const SourceManager &getSourceManager() const { return *SourceMgr; } SourceManager &getSourceManager() { return *SourceMgr; } @@ -407,6 +450,8 @@ public: const ASTContext &getASTContext() const { return *Ctx; } ASTContext &getASTContext() { return *Ctx; } + void setASTContext(ASTContext *ctx) { Ctx = ctx; } + bool hasSema() const { return TheSema; } Sema &getSema() const { assert(TheSema && "ASTUnit does not have a Sema object!"); @@ -419,7 +464,6 @@ public: const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } const std::string &getOriginalSourceFileName(); - const std::string &getASTFileName(); /// \brief Add a temporary file that the ASTUnit depends on. /// @@ -433,15 +477,11 @@ public: bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; } void setOwnsRemappedFileBuffers(bool val) { OwnsRemappedFileBuffers = val; } - /// \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; + StringRef getMainFileName() const; typedef std::vector<Decl *>::iterator top_level_iterator; @@ -484,22 +524,38 @@ public: /// /// 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 Get the source location for the given file:line:col triplet. + /// + /// The difference with SourceManager::getLocation is that this method checks + /// whether the requested location points inside the precompiled preamble + /// in which case the returned source location will be a "loaded" one. + SourceLocation getLocation(const FileEntry *File, + unsigned Line, unsigned Col) const; + + /// \brief Get the source location for the given file:offset pair. + SourceLocation getLocation(const FileEntry *File, unsigned Offset) const; + + /// \brief If \arg Loc is a loaded location from the preamble, returns + /// the corresponding local location of the main file, otherwise it returns + /// \arg Loc. + SourceLocation mapLocationFromPreamble(SourceLocation Loc); + + /// \brief If \arg Loc is a local location of the main file but inside the + /// preamble chunk, returns the corresponding loaded location from the + /// preamble, otherwise it returns \arg Loc. + SourceLocation mapLocationToPreamble(SourceLocation Loc); + + /// \brief \see mapLocationFromPreamble. + SourceRange mapRangeFromPreamble(SourceRange R) { + return SourceRange(mapLocationFromPreamble(R.getBegin()), + mapLocationFromPreamble(R.getEnd())); } - - /// \brief Retrieve the mapping from File IDs to the preprocessed entities - /// within that file. - PreprocessedEntitiesByFileMap &getPreprocessedEntitiesByFile() { - return PreprocessedEntitiesByFile; + + /// \brief \see mapLocationToPreamble. + SourceRange mapRangeToPreamble(SourceRange R) { + return SourceRange(mapLocationToPreamble(R.getBegin()), + mapLocationToPreamble(R.getEnd())); } // Retrieve the diagnostics associated with this AST @@ -512,7 +568,7 @@ public: } unsigned stored_diag_size() const { return StoredDiagnostics.size(); } - llvm::SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() { + SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() { return StoredDiagnostics; } @@ -531,14 +587,11 @@ public: return CachedCompletionResults.size(); } - llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename, + llvm::MemoryBuffer *getBufferForFile(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 Determine what kind of translation unit this AST represents. + TranslationUnitKind getTranslationUnitKind() const { return TUKind; } typedef llvm::PointerUnion<const char *, const llvm::MemoryBuffer *> FilenameOrMemBuf; @@ -548,7 +601,7 @@ public: /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation. static ASTUnit *create(CompilerInvocation *CI, - llvm::IntrusiveRefCntPtr<Diagnostic> Diags); + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags); /// \brief Create a ASTUnit from an AST file. /// @@ -559,7 +612,7 @@ public: /// /// \returns - The initialized ASTUnit or null if the AST failed to load. static ASTUnit *LoadFromASTFile(const std::string &Filename, - llvm::IntrusiveRefCntPtr<Diagnostic> Diags, + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags, const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls = false, RemappedFile *RemappedFiles = 0, @@ -590,9 +643,13 @@ public: /// /// \param Action - The ASTFrontendAction to invoke. Its ownership is not /// transfered. + /// + /// \param Unit - optionally an already created ASTUnit. Its ownership is not + /// transfered. static ASTUnit *LoadFromCompilerInvocationAction(CompilerInvocation *CI, - llvm::IntrusiveRefCntPtr<Diagnostic> Diags, - ASTFrontendAction *Action = 0); + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags, + ASTFrontendAction *Action = 0, + ASTUnit *Unit = 0); /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a /// CompilerInvocation object. @@ -606,11 +663,11 @@ public: // 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, + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, bool PrecompilePreamble = false, - bool CompleteTranslationUnit = true, + TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, bool NestedMacroExpansions = true); @@ -630,18 +687,16 @@ public: // 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, + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags, + StringRef ResourceFilesPath, bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, RemappedFile *RemappedFiles = 0, unsigned NumRemappedFiles = 0, bool RemappedFilesKeepOriginalName = true, bool PrecompilePreamble = false, - bool CompleteTranslationUnit = true, + TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, - bool CXXPrecompilePreamble = false, - bool CXXChainedPCH = false, bool NestedMacroExpansions = true); /// \brief Reparse the source files using the same command-line options that @@ -669,24 +724,31 @@ public: /// /// 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, + void CodeComplete(StringRef File, unsigned Line, unsigned Column, RemappedFile *RemappedFiles, unsigned NumRemappedFiles, bool IncludeMacros, bool IncludeCodePatterns, CodeCompleteConsumer &Consumer, - Diagnostic &Diag, LangOptions &LangOpts, + DiagnosticsEngine &Diag, LangOptions &LangOpts, SourceManager &SourceMgr, FileManager &FileMgr, - llvm::SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics, - llvm::SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers); + SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics, + SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers); /// \brief Save this translation unit to a file with the given name. /// /// \returns An indication of whether the save was successful or not. - CXSaveError Save(llvm::StringRef File); + CXSaveError Save(StringRef File); /// \brief Serialize this translation unit with the given output stream. /// /// \returns True if an error occurred, false otherwise. - bool serialize(llvm::raw_ostream &OS); + bool serialize(raw_ostream &OS); + + virtual ModuleKey loadModule(SourceLocation ImportLoc, + IdentifierInfo &ModuleName, + SourceLocation ModuleNameLoc) { + // ASTUnit doesn't know how to load modules (not that this matters). + return 0; + } }; } // namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def b/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def index f055549..010f889 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/Analyses.def @@ -15,9 +15,7 @@ #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) @@ -30,13 +28,21 @@ ANALYSIS_CONSTRAINTS(RangeConstraints, "range", "Use constraint tracking of conc #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) +ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML", createHTMLDiagnosticConsumer, false) +ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", createPlistDiagnosticConsumer, true) +ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", "Output analysis results using HTML wrapped with Plists", createPlistHTMLDiagnosticConsumer, true) +ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results", createTextPathDiagnosticConsumer, true) + +#ifndef ANALYSIS_PURGE +#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC) +#endif + +ANALYSIS_PURGE(PurgeStmt, "statement", "Purge symbols, bindings, and constraints before every statement") +ANALYSIS_PURGE(PurgeBlock, "block", "Purge symbols, bindings, and constraints before every basic block") +ANALYSIS_PURGE(PurgeNone, "none", "Do not purge symbols, bindings, or constraints") #undef ANALYSIS_STORE #undef ANALYSIS_CONSTRAINTS #undef ANALYSIS_DIAGNOSTICS -#undef ANALYSIS_STORE +#undef ANALYSIS_PURGE diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h index ea9f5e3..3565a51 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/AnalyzerOptions.h @@ -20,7 +20,7 @@ namespace clang { class ASTConsumer; -class Diagnostic; +class DiagnosticsEngine; class Preprocessor; class LangOptions; @@ -53,6 +53,13 @@ enum AnalysisDiagClients { NUM_ANALYSIS_DIAG_CLIENTS }; +/// AnalysisPurgeModes - Set of available strategies for dead symbol removal. +enum AnalysisPurgeMode { +#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC) NAME, +#include "clang/Frontend/Analyses.def" +NumPurgeModes +}; + class AnalyzerOptions { public: /// \brief Pair of checker name and enable/disable. @@ -60,6 +67,7 @@ public: AnalysisStores AnalysisStoreOpt; AnalysisConstraints AnalysisConstraintsOpt; AnalysisDiagClients AnalysisDiagOpt; + AnalysisPurgeMode AnalysisPurgeOpt; std::string AnalyzeSpecificFunction; unsigned MaxNodes; unsigned MaxLoop; @@ -68,7 +76,6 @@ public: unsigned AnalyzerDisplayProgress : 1; unsigned AnalyzeNestedBlocks : 1; unsigned EagerlyAssume : 1; - unsigned PurgeDead : 1; unsigned TrimGraph : 1; unsigned VisualizeEGDot : 1; unsigned VisualizeEGUbi : 1; @@ -80,15 +87,15 @@ public: public: AnalyzerOptions() { - AnalysisStoreOpt = BasicStoreModel; + AnalysisStoreOpt = RegionStoreModel; AnalysisConstraintsOpt = RangeConstraintsModel; AnalysisDiagOpt = PD_HTML; + AnalysisPurgeOpt = PurgeStmt; ShowCheckerHelp = 0; AnalyzeAll = 0; AnalyzerDisplayProgress = 0; AnalyzeNestedBlocks = 0; EagerlyAssume = 0; - PurgeDead = 1; TrimGraph = 0; VisualizeEGDot = 0; VisualizeEGUbi = 0; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticClient.h b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h index 70f2190..f20cf6f 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticClient.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h @@ -1,4 +1,4 @@ -//===--- ChainedDiagnosticClient.h - Chain Diagnostic Clients ---*- C++ -*-===// +//===- ChainedDiagnosticConsumer.h - Chain Diagnostic Clients ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H -#define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H +#ifndef LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCONSUMER_H +#define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCONSUMER_H #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/OwningPtr.h" @@ -16,17 +16,17 @@ namespace clang { class LangOptions; -/// ChainedDiagnosticClient - Chain two diagnostic clients so that diagnostics +/// ChainedDiagnosticConsumer - 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; +class ChainedDiagnosticConsumer : public DiagnosticConsumer { + llvm::OwningPtr<DiagnosticConsumer> Primary; + llvm::OwningPtr<DiagnosticConsumer> Secondary; public: - ChainedDiagnosticClient(DiagnosticClient *_Primary, - DiagnosticClient *_Secondary) { + ChainedDiagnosticConsumer(DiagnosticConsumer *_Primary, + DiagnosticConsumer *_Secondary) { Primary.reset(_Primary); Secondary.reset(_Secondary); } @@ -46,14 +46,20 @@ public: return Primary->IncludeInDiagnosticCounts(); } - virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, - const DiagnosticInfo &Info) { + virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info) { // Default implementation (Warnings/errors count). - DiagnosticClient::HandleDiagnostic(DiagLevel, Info); + DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info); Primary->HandleDiagnostic(DiagLevel, Info); Secondary->HandleDiagnostic(DiagLevel, Info); } + + DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const { + return new ChainedDiagnosticConsumer(Primary->clone(Diags), + Secondary->clone(Diags)); + } + }; } // end namspace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h index 5d040b4..4874c17 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h @@ -37,6 +37,7 @@ public: unsigned AsmVerbose : 1; /// -dA, -fverbose-asm. unsigned ObjCAutoRefCountExceptions : 1; /// Whether ARC should be EH-safe. + unsigned CUDAIsDevice : 1; /// Set when compiling for CUDA device. unsigned CXAAtExit : 1; /// Use __cxa_atexit for calling destructors. unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker /// aliases to base ctors when possible. @@ -71,6 +72,7 @@ public: unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled. unsigned NoDwarf2CFIAsm : 1; /// Set when -fno-dwarf2-cfi-asm is enabled. unsigned NoExecStack : 1; /// Set when -Wa,--noexecstack is enabled. + unsigned NoGlobalMerge : 1; /// Set when -mno-global-merge 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. @@ -142,6 +144,7 @@ public: public: CodeGenOptions() { AsmVerbose = 0; + CUDAIsDevice = 0; CXAAtExit = 1; CXXCtorDtorAliases = 0; DataSections = 0; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h b/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h index 8911cfa..c01f91d 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CommandLineSourceLoc.h @@ -15,6 +15,7 @@ #ifndef LLVM_CLANG_FRONTEND_COMMANDLINESOURCELOC_H #define LLVM_CLANG_FRONTEND_COMMANDLINESOURCELOC_H +#include "clang/Basic/LLVM.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" @@ -29,10 +30,10 @@ struct ParsedSourceLocation { public: /// Construct a parsed source location from a string; the Filename is empty on /// error. - static ParsedSourceLocation FromString(llvm::StringRef Str) { + static ParsedSourceLocation FromString(StringRef Str) { ParsedSourceLocation PSL; - std::pair<llvm::StringRef, llvm::StringRef> ColSplit = Str.rsplit(':'); - std::pair<llvm::StringRef, llvm::StringRef> LineSplit = + std::pair<StringRef, StringRef> ColSplit = Str.rsplit(':'); + std::pair<StringRef, StringRef> LineSplit = ColSplit.first.rsplit(':'); // If both tail splits were valid integers, return success. diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h index 004c889..8817740 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ #include "clang/Frontend/CompilerInvocation.h" +#include "clang/Lex/ModuleLoader.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/OwningPtr.h" @@ -19,7 +20,6 @@ #include <string> namespace llvm { -class raw_ostream; class raw_fd_ostream; class Timer; } @@ -27,13 +27,13 @@ class Timer; namespace clang { class ASTContext; class ASTConsumer; +class ASTReader; class CodeCompleteConsumer; -class Diagnostic; -class DiagnosticClient; +class DiagnosticsEngine; +class DiagnosticConsumer; class ExternalASTSource; class FileManager; class FrontendAction; -class ASTReader; class Preprocessor; class Sema; class SourceManager; @@ -57,12 +57,12 @@ class TargetInfo; /// 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 { +class CompilerInstance : public ModuleLoader { /// The options used in this compiler instance. llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation; /// The diagnostics engine instance. - llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; /// The target being compiled for. llvm::IntrusiveRefCntPtr<TargetInfo> Target; @@ -88,9 +88,12 @@ class CompilerInstance { /// \brief The semantic analysis object. llvm::OwningPtr<Sema> TheSema; - /// The frontend timer + /// \brief The frontend timer llvm::OwningPtr<llvm::Timer> FrontendTimer; + /// \brief Non-owning reference to the ASTReader, if one exists. + ASTReader *ModuleManager; + /// \brief Holds information about the output file. /// /// If TempFilename is not empty we must rename it to Filename at the end. @@ -99,10 +102,10 @@ class CompilerInstance { struct OutputFile { std::string Filename; std::string TempFilename; - llvm::raw_ostream *OS; + raw_ostream *OS; OutputFile(const std::string &filename, const std::string &tempFilename, - llvm::raw_ostream *os) + raw_ostream *os) : Filename(filename), TempFilename(tempFilename), OS(os) { } }; @@ -249,15 +252,15 @@ public: bool hasDiagnostics() const { return Diagnostics != 0; } /// Get the current diagnostics engine. - Diagnostic &getDiagnostics() const { + DiagnosticsEngine &getDiagnostics() const { assert(Diagnostics && "Compiler instance has no diagnostics!"); return *Diagnostics; } /// setDiagnostics - Replace the current diagnostics engine. - void setDiagnostics(Diagnostic *Value); + void setDiagnostics(DiagnosticsEngine *Value); - DiagnosticClient &getDiagnosticClient() const { + DiagnosticConsumer &getDiagnosticClient() const { assert(Diagnostics && Diagnostics->getClient() && "Compiler instance has no diagnostic client!"); return *Diagnostics->getClient(); @@ -388,6 +391,12 @@ public: Sema *takeSema() { return TheSema.take(); } /// } + /// @name Module Management + /// { + + ASTReader *getModuleManager() const { return ModuleManager; } + + /// } /// @name Code Completion /// { @@ -446,38 +455,48 @@ public: /// 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 + /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST /// unit. + /// + /// \param ShouldOwnClient If Client is non-NULL, specifies whether + /// the diagnostic object should take ownership of the client. + /// + /// \param ShouldCloneClient If Client is non-NULL, specifies whether that + /// client should be cloned. void createDiagnostics(int Argc, const char* const *Argv, - DiagnosticClient *Client = 0); + DiagnosticConsumer *Client = 0, + bool ShouldOwnClient = true, + bool ShouldCloneClient = true); - /// Create a Diagnostic object with a the TextDiagnosticPrinter. + /// Create a DiagnosticsEngine 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 + /// DiagnosticConsumer that is owned by the returned diagnostic /// object, if using directly the caller is responsible for - /// releasing the returned Diagnostic's client eventually. + /// releasing the returned DiagnosticsEngine'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 + /// attached to (and, then, owned by) the returned DiagnosticsEngine /// object. /// /// \param CodeGenOpts If non-NULL, the code gen options in use, which may be /// used by some diagnostics printers (for logging purposes only). /// /// \return The new object on success, or null on failure. - static llvm::IntrusiveRefCntPtr<Diagnostic> + static llvm::IntrusiveRefCntPtr<DiagnosticsEngine> createDiagnostics(const DiagnosticOptions &Opts, int Argc, const char* const *Argv, - DiagnosticClient *Client = 0, + DiagnosticConsumer *Client = 0, + bool ShouldOwnClient = true, + bool ShouldCloneClient = true, const CodeGenOptions *CodeGenOpts = 0); /// Create the file manager and replace any existing one with it. @@ -490,26 +509,12 @@ public: /// 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, + void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation, bool DisableStatCache, void *DeserializationListener); @@ -518,7 +523,7 @@ public: /// /// \return - The new object on success, or null on failure. static ExternalASTSource * - createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot, + createPCHExternalASTSource(StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, bool DisableStatCache, Preprocessor &PP, ASTContext &Context, @@ -537,10 +542,10 @@ public: unsigned Line, unsigned Column, bool ShowMacros, bool ShowCodePatterns, bool ShowGlobals, - llvm::raw_ostream &OS); + raw_ostream &OS); /// \brief Create the Sema object to be used for parsing. - void createSema(bool CompleteTranslationUnit, + void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer); /// Create the frontend timer and replace any existing one with it. @@ -551,25 +556,27 @@ public: /// /// \return - Null on error. llvm::raw_fd_ostream * - createDefaultOutputFile(bool Binary = true, llvm::StringRef BaseInput = "", - llvm::StringRef Extension = ""); + createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "", + 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, + createOutputFile(StringRef OutputPath, bool Binary = true, bool RemoveFileOnSignal = true, - llvm::StringRef BaseInput = "", - llvm::StringRef Extension = ""); + StringRef BaseInput = "", + StringRef Extension = "", + bool UseTemporary = false); /// 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. + /// Extension appended. If OutputPath is not stdout and \arg UseTemporary + /// is true, 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. @@ -580,15 +587,18 @@ public: /// \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 UseTemporary - Create a new temporary file that must be renamed to + /// OutputPath in the end /// \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, + createOutputFile(StringRef OutputPath, std::string &Error, bool Binary = true, bool RemoveFileOnSignal = true, - llvm::StringRef BaseInput = "", - llvm::StringRef Extension = "", + StringRef BaseInput = "", + StringRef Extension = "", + bool UseTemporary = false, std::string *ResultPathName = 0, std::string *TempPathName = 0); @@ -600,19 +610,23 @@ public: /// as the main file. /// /// \return True on success. - bool InitializeSourceManager(llvm::StringRef InputFile); + bool InitializeSourceManager(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, + static bool InitializeSourceManager(StringRef InputFile, + DiagnosticsEngine &Diags, FileManager &FileMgr, SourceManager &SourceMgr, const FrontendOptions &Opts); /// } + + virtual ModuleKey loadModule(SourceLocation ImportLoc, + IdentifierInfo &ModuleName, + SourceLocation ModuleNameLoc); }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h index e18f3fe..47c7031 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h @@ -28,13 +28,9 @@ #include <string> #include <vector> -namespace llvm { - template<typename T> class SmallVectorImpl; -} - namespace clang { -class Diagnostic; +class DiagnosticsEngine; /// CompilerInvocation - Helper class for holding the data necessary to invoke /// the compiler. @@ -92,7 +88,7 @@ public: static void CreateFromArgs(CompilerInvocation &Res, const char* const *ArgBegin, const char* const *ArgEnd, - Diagnostic &Diags); + DiagnosticsEngine &Diags); /// GetBuiltinIncludePath - Get the directory where the compiler headers /// reside, relative to the compiler binary (found by the passed in @@ -127,6 +123,10 @@ public: static void setLangDefaults(LangOptions &Opts, InputKind IK, LangStandard::Kind LangStd = LangStandard::lang_unspecified); + /// \brief Retrieve a module hash string that is suitable for uniquely + /// identifying the conditions under which the module was built. + std::string getModuleHash() const; + /// @} /// @name Option Subgroups /// @{ diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h index 5ae8eb3..319abeb 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticOptions.h @@ -43,7 +43,7 @@ public: unsigned ShowColors : 1; /// Show diagnostics with ANSI color sequences. unsigned ShowOverloads : 1; /// Overload candidates to show. Values from - /// Diagnostic::OverloadsShown + /// DiagnosticsEngine::OverloadsShown unsigned VerifyDiagnostics: 1; /// Check that diagnostics match the expected /// diagnostics, indicated by markers in the /// input source file. @@ -82,7 +82,7 @@ public: PedanticErrors = 0; ShowCarets = 1; ShowColors = 0; - ShowOverloads = Diagnostic::Ovl_All; + ShowOverloads = DiagnosticsEngine::Ovl_All; ShowColumn = 1; ShowFixits = 1; ShowLocation = 1; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h index f335475..f85cc7e 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h @@ -10,15 +10,13 @@ #ifndef LLVM_CLANG_FRONTEND_FRONTENDACTION_H #define LLVM_CLANG_FRONTEND_FRONTENDACTION_H +#include "clang/Basic/LLVM.h" +#include "clang/Basic/LangOptions.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; @@ -55,7 +53,7 @@ class FrontendAction { private: ASTConsumer* CreateWrappedASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); protected: /// @name Implementation Action Interface @@ -76,7 +74,7 @@ protected: /// /// \return The new AST consumer, or 0 on failure. virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile) = 0; + StringRef InFile) = 0; /// \brief Callback before starting processing a single input, giving the /// opportunity to modify the CompilerInvocation or do some other action @@ -92,7 +90,7 @@ protected: /// \return True on success; on failure \see ExecutionAction() and /// EndSourceFileAction() will not be called. virtual bool BeginSourceFileAction(CompilerInstance &CI, - llvm::StringRef Filename) { + StringRef Filename) { return true; } @@ -152,7 +150,7 @@ public: return CurrentASTUnit.take(); } - void setCurrentFile(llvm::StringRef Value, InputKind Kind, ASTUnit *AST = 0); + void setCurrentFile(StringRef Value, InputKind Kind, ASTUnit *AST = 0); /// @} /// @name Supported Modes @@ -163,9 +161,8 @@ public: /// file inputs. virtual bool usesPreprocessorOnly() const = 0; - /// usesCompleteTranslationUnit - For AST based actions, should the - /// translation unit be completed? - virtual bool usesCompleteTranslationUnit() { return true; } + /// \brief For AST-based actions, the kind of translation unit we're handling. + virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; } /// hasPCHSupport - Does this action support use with PCH? virtual bool hasPCHSupport() const { return !usesPreprocessorOnly(); } @@ -205,7 +202,7 @@ public: /// /// \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, + bool BeginSourceFile(CompilerInstance &CI, StringRef Filename, InputKind Kind); /// Execute - Set the source managers main input file, and run the action. @@ -236,7 +233,7 @@ public: class PluginASTAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile) = 0; + StringRef InFile) = 0; public: /// ParseArgs - Parse the given plugin command line arguments. @@ -256,7 +253,7 @@ 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); + StringRef InFile); public: virtual bool usesPreprocessorOnly() const { return true; } @@ -272,10 +269,10 @@ class WrapperFrontendAction : public FrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); virtual bool BeginInvocation(CompilerInstance &CI); virtual bool BeginSourceFileAction(CompilerInstance &CI, - llvm::StringRef Filename); + StringRef Filename); virtual void ExecuteAction(); virtual void EndSourceFileAction(); @@ -285,7 +282,7 @@ public: WrapperFrontendAction(FrontendAction *WrappedAction); virtual bool usesPreprocessorOnly() const; - virtual bool usesCompleteTranslationUnit(); + virtual TranslationUnitKind getTranslationUnitKind(); virtual bool hasPCHSupport() const; virtual bool hasASTFileSupport() const; virtual bool hasIRSupport() const; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h index b409ad1..72a3d90 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h @@ -24,7 +24,7 @@ class InitOnlyAction : public FrontendAction { virtual void ExecuteAction(); virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); public: // Don't claim to only use the preprocessor, we want to follow the AST path, @@ -39,59 +39,65 @@ public: class ASTPrintAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); }; class ASTDumpAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); }; class ASTDumpXMLAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); }; class ASTViewAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); }; class DeclContextPrintAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); }; class GeneratePCHAction : public ASTFrontendAction { + bool MakeModule; + protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); - virtual bool usesCompleteTranslationUnit() { return false; } + virtual TranslationUnitKind getTranslationUnitKind() { + return MakeModule? TU_Module : TU_Prefix; + } virtual bool hasASTFileSupport() const { return false; } public: + /// \brief Create a new action + explicit GeneratePCHAction(bool MakeModule) : MakeModule(MakeModule) { } + /// \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, + StringRef InFile, std::string &Sysroot, std::string &OutputFile, - llvm::raw_ostream *&OS, - bool &Chaining); + raw_ostream *&OS); }; class SyntaxOnlyAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); public: virtual bool hasCodeCompletionSupport() const { return true; } @@ -114,10 +120,10 @@ class ASTMergeAction : public FrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); + StringRef InFile); virtual bool BeginSourceFileAction(CompilerInstance &CI, - llvm::StringRef Filename); + StringRef Filename); virtual void ExecuteAction(); virtual void EndSourceFileAction(); @@ -128,7 +134,7 @@ public: virtual ~ASTMergeAction(); virtual bool usesPreprocessorOnly() const; - virtual bool usesCompleteTranslationUnit(); + virtual TranslationUnitKind getTranslationUnitKind(); virtual bool hasPCHSupport() const; virtual bool hasASTFileSupport() const; virtual bool hasCodeCompletionSupport() const; @@ -137,7 +143,7 @@ public: class PrintPreambleAction : public FrontendAction { protected: void ExecuteAction(); - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &, llvm::StringRef) { + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef) { return 0; } diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h index 3e9508c..21cd2c6 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendDiagnostic.h @@ -16,7 +16,7 @@ namespace clang { namespace diag { enum { #define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\ - SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM, + SFINAE,ACCESS,NOWERROR,SHOWINSYSHEADER,CATEGORY,BRIEF,FULL) ENUM, #define FRONTENDSTART #include "clang/Basic/DiagnosticFrontendKinds.inc" #undef DIAG diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h index 225a955..fa6d044 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h @@ -24,7 +24,6 @@ namespace frontend { ASTDumpXML, ///< Parse ASTs and dump them in XML. ASTPrint, ///< Parse ASTs and print them. ASTView, ///< Parse ASTs and view them in Graphviz. - CreateModule, ///< Create module definition DumpRawTokens, ///< Dump out raw tokens. DumpTokens, ///< Dump out preprocessed tokens. EmitAssembly, ///< Emit a .s file. @@ -35,6 +34,7 @@ namespace frontend { EmitCodeGenOnly, ///< Generate machine code, but don't emit anything. EmitObj, ///< Emit a .o file. FixIt, ///< Parse and apply any fixits to the source. + GenerateModule, ///< Generate pre-compiled module. GeneratePCH, ///< Generate pre-compiled header. GeneratePTH, ///< Generate pre-tokenized header. InitOnly, ///< Only execute frontend initialization. @@ -58,9 +58,6 @@ public: 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. @@ -75,6 +72,8 @@ public: unsigned ShowVersion : 1; ///< Show the -version text. unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are /// unfixable errors. + unsigned ARCMTMigrateEmitARCErrors : 1; /// Emit ARC errors even if the + /// migrator can fix them enum { ARCMT_None, @@ -84,6 +83,7 @@ public: } ARCMTAction; std::string ARCMTMigrateDir; + std::string ARCMTMigrateReportOut; /// The input files and their types. std::vector<std::pair<InputKind, std::string> > Inputs; @@ -118,9 +118,6 @@ public: /// \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; @@ -131,7 +128,6 @@ public: ProgramAction = frontend::ParseSyntaxOnly; ActionName = ""; RelocatablePCH = 0; - ChainedPCH = 0; ShowHelp = 0; ShowMacrosInCodeCompletion = 0; ShowCodePatternsInCodeCompletion = 0; @@ -140,6 +136,7 @@ public: ShowTimers = 0; ShowVersion = 0; ARCMTAction = ARCMT_None; + ARCMTMigrateEmitARCErrors = 0; } /// getInputKindForExtension - Return the appropriate input kind for a file @@ -147,7 +144,7 @@ public: /// /// \return The input kind for the extension, or IK_None if the extension is /// not recognized. - static InputKind getInputKindForExtension(llvm::StringRef Extension); + static InputKind getInputKindForExtension(StringRef Extension); }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h index 0347f98..92790e9 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/HeaderSearchOptions.h @@ -23,8 +23,13 @@ namespace frontend { enum IncludeDirGroup { Quoted = 0, ///< '#include ""' paths, added by'gcc -iquote'. Angled, ///< Paths for '#include <>' added by '-I'. + IndexHeaderMap, ///< Like Angled, but marks header maps used when + /// building frameworks. System, ///< Like Angled, but marks system directories. + CSystem, ///< Like System, but only used for C. CXXSystem, ///< Like System, but only used for C++. + ObjCSystem, ///< Like System, but only used for ObjC. + ObjCXXSystem, ///< Like System, but only used for ObjC++. After ///< Like System, but searched after the system directories. }; } @@ -44,7 +49,7 @@ public: /// path. unsigned IgnoreSysRoot : 1; - Entry(llvm::StringRef path, frontend::IncludeDirGroup group, + Entry(StringRef path, frontend::IncludeDirGroup group, bool isUserSupplied, bool isFramework, bool ignoreSysRoot) : Path(path), Group(group), IsUserSupplied(isUserSupplied), IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot) {} @@ -57,27 +62,24 @@ public: /// User specified include entries. std::vector<Entry> UserEntries; - /// 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; + /// \brief The directory used for the module cache. + std::string ModuleCachePath; + + /// \brief Whether we should disable the use of the hash string within the + /// module cache. + /// + /// Note: Only used for testing! + unsigned DisableModuleHash : 1; + /// Include the compiler builtin includes. unsigned UseBuiltinIncludes : 1; /// Include the system standard include search directories. - unsigned UseStandardIncludes : 1; + unsigned UseStandardSystemIncludes : 1; /// Include the system standard C++ library include search directories. unsigned UseStandardCXXIncludes : 1; @@ -89,13 +91,13 @@ public: unsigned Verbose : 1; public: - HeaderSearchOptions(llvm::StringRef _Sysroot = "/") - : Sysroot(_Sysroot), UseBuiltinIncludes(true), - UseStandardIncludes(true), UseStandardCXXIncludes(true), UseLibcxx(false), - Verbose(false) {} + HeaderSearchOptions(StringRef _Sysroot = "/") + : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true), + UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), + UseLibcxx(false), Verbose(false) {} /// AddPath - Add the \arg Path path to the specified \arg Group list. - void AddPath(llvm::StringRef Path, frontend::IncludeDirGroup Group, + void AddPath(StringRef Path, frontend::IncludeDirGroup Group, bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot) { UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework, IgnoreSysRoot)); diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h index ea37bdd..de2800c 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h @@ -10,6 +10,7 @@ #ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H #define LLVM_CLANG_FRONTEND_LANGSTANDARD_H +#include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" namespace clang { @@ -83,7 +84,7 @@ public: bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; } static const LangStandard &getLangStandardForKind(Kind K); - static const LangStandard *getLangStandardForName(llvm::StringRef Name); + static const LangStandard *getLangStandardForName(StringRef Name); }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def index 6055ad5..c82290b 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def @@ -37,6 +37,9 @@ LANGSTANDARD(c94, "iso9899:199409", LANGSTANDARD(gnu89, "gnu89", "ISO C 1990 with GNU extensions", BCPLComment | C89 | Digraphs | GNUMode | ImplicitInt) +LANGSTANDARD(gnu90, "gnu90", + "ISO C 1990 with GNU extensions", + BCPLComment | C89 | Digraphs | GNUMode | ImplicitInt) // C99-ish modes LANGSTANDARD(c99, "c99", @@ -75,15 +78,24 @@ LANGSTANDARD(gnu1x, "gnu1x", LANGSTANDARD(cxx98, "c++98", "ISO C++ 1998 with amendments", BCPLComment | CPlusPlus | Digraphs) +LANGSTANDARD(cxx03, "c++03", + "ISO C++ 1998 with amendments", + BCPLComment | CPlusPlus | Digraphs) LANGSTANDARD(gnucxx98, "gnu++98", - "ISO C++ 1998 with " "amendments and GNU extensions", + "ISO C++ 1998 with amendments and GNU extensions", BCPLComment | CPlusPlus | Digraphs | GNUMode) LANGSTANDARD(cxx0x, "c++0x", - "Upcoming ISO C++ 200x with amendments", + "ISO C++ 2011 with amendments", + BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs) +LANGSTANDARD(cxx11, "c++11", + "ISO C++ 2011 with amendments", BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs) LANGSTANDARD(gnucxx0x, "gnu++0x", - "Upcoming ISO C++ 200x with amendments and GNU extensions", + "ISO C++ 2011 with amendments and GNU extensions", + BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) +LANGSTANDARD(gnucxx11, "gnu++11", + "ISO C++ 2011 with amendments and GNU extensions", BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) // OpenCL diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h b/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h index b6fc23c..4de15f2 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h @@ -19,7 +19,7 @@ namespace clang { class DiagnosticOptions; class LangOptions; -class LogDiagnosticPrinter : public DiagnosticClient { +class LogDiagnosticPrinter : public DiagnosticConsumer { struct DiagEntry { /// The primary message line of the diagnostic. std::string Message; @@ -37,10 +37,10 @@ class LogDiagnosticPrinter : public DiagnosticClient { unsigned DiagnosticID; /// The level of the diagnostic. - Diagnostic::Level DiagnosticLevel; + DiagnosticsEngine::Level DiagnosticLevel; }; - llvm::raw_ostream &OS; + raw_ostream &OS; const LangOptions *LangOpts; const DiagnosticOptions *DiagOpts; @@ -48,17 +48,17 @@ class LogDiagnosticPrinter : public DiagnosticClient { FullSourceLoc LastLoc; unsigned OwnsOutputStream : 1; - llvm::SmallVector<DiagEntry, 8> Entries; + SmallVector<DiagEntry, 8> Entries; std::string MainFilename; std::string DwarfDebugFlags; public: - LogDiagnosticPrinter(llvm::raw_ostream &OS, const DiagnosticOptions &Diags, + LogDiagnosticPrinter(raw_ostream &OS, const DiagnosticOptions &Diags, bool OwnsOutputStream = false); virtual ~LogDiagnosticPrinter(); - void setDwarfDebugFlags(llvm::StringRef Value) { + void setDwarfDebugFlags(StringRef Value) { DwarfDebugFlags = Value; } @@ -68,8 +68,10 @@ public: void EndSourceFile(); - virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, - const DiagnosticInfo &Info); + virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info); + + DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const; }; } // 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 index 2e16c97..0ee8cb3 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOptions.h @@ -50,6 +50,10 @@ public: /// record of all macro definitions and /// expansions. + /// \brief Whether we should automatically translate #include or #import + /// operations into module imports when possible. + unsigned AutoModuleImport : 1; + /// \brief Whether the detailed preprocessing record includes nested macro /// expansions. unsigned DetailedRecordIncludesNestedMacroExpansions : 1; @@ -117,6 +121,14 @@ public: /// by providing appropriate definitions to retrofit the standard library /// with support for lifetime-qualified pointers. ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary; + + /// \brief The path of modules being build, which is used to detect + /// cycles in the module dependency graph as modules are being built. + /// + /// There is no way to set this value from the command line. If we ever need + /// to do so (e.g., if on-demand module construction moves out-of-process), + /// we can add a cc1-level option to do so. + SmallVector<std::string, 2> ModuleBuildPath; typedef std::vector<std::pair<std::string, std::string> >::iterator remapped_file_iterator; @@ -154,6 +166,7 @@ public: public: PreprocessorOptions() : UsePredefines(true), DetailedRecord(false), + AutoModuleImport(false), DetailedRecordIncludesNestedMacroExpansions(true), DisablePCHValidation(false), DisableStatCache(false), DumpDeserializedPCHDecls(false), @@ -162,13 +175,13 @@ public: RetainRemappedFileBuffers(false), ObjCXXARCStandardLibrary(ARCXX_nolib) { } - void addMacroDef(llvm::StringRef Name) { + void addMacroDef(StringRef Name) { Macros.push_back(std::make_pair(Name, false)); } - void addMacroUndef(llvm::StringRef Name) { + void addMacroUndef(StringRef Name) { Macros.push_back(std::make_pair(Name, true)); } - void addRemappedFile(llvm::StringRef From, llvm::StringRef To) { + void addRemappedFile(StringRef From, StringRef To) { RemappedFiles.push_back(std::make_pair(From, To)); } @@ -176,7 +189,7 @@ public: return RemappedFiles.erase(Remapped); } - void addRemappedFile(llvm::StringRef From, const llvm::MemoryBuffer * To) { + void addRemappedFile(StringRef From, const llvm::MemoryBuffer * To) { RemappedFileBuffers.push_back(std::make_pair(From, To)); } @@ -189,6 +202,21 @@ public: RemappedFiles.clear(); RemappedFileBuffers.clear(); } + + /// \brief Reset any options that are not considered when building a + /// module. + void resetNonModularOptions() { + Includes.clear(); + MacroIncludes.clear(); + ChainedIncludes.clear(); + DumpDeserializedPCHDecls = false; + ImplicitPCHInclude.clear(); + ImplicitPTHInclude.clear(); + TokenCache.clear(); + RetainRemappedFileBuffers = true; + PrecompiledPreambleBytes.first = 0; + PrecompiledPreambleBytes.second = 0; + } }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h index 380a1dd..6f1c0e8 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h @@ -22,7 +22,7 @@ namespace clang { class Preprocessor; class SourceManager; -class TextDiagnosticBuffer : public DiagnosticClient { +class TextDiagnosticBuffer : public DiagnosticConsumer { public: typedef std::vector<std::pair<SourceLocation, std::string> > DiagList; typedef DiagList::iterator iterator; @@ -39,12 +39,14 @@ public: 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); + virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info); /// FlushDiagnostics - Flush the buffered diagnostics to an given /// diagnostic engine. - void FlushDiagnostics(Diagnostic &Diags) const; + void FlushDiagnostics(DiagnosticsEngine &Diags) const; + + virtual DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const; }; } // end namspace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h index 79a9916..22fa18b 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h @@ -22,8 +22,8 @@ namespace clang { class DiagnosticOptions; class LangOptions; -class TextDiagnosticPrinter : public DiagnosticClient { - llvm::raw_ostream &OS; +class TextDiagnosticPrinter : public DiagnosticConsumer { + raw_ostream &OS; const LangOptions *LangOpts; const DiagnosticOptions *DiagOpts; @@ -36,7 +36,7 @@ class TextDiagnosticPrinter : public DiagnosticClient { std::string Prefix; public: - TextDiagnosticPrinter(llvm::raw_ostream &os, const DiagnosticOptions &diags, + TextDiagnosticPrinter(raw_ostream &os, const DiagnosticOptions &diags, bool OwnsOutputStream = false); virtual ~TextDiagnosticPrinter(); @@ -53,26 +53,19 @@ public: LangOpts = 0; } - void PrintIncludeStack(Diagnostic::Level Level, SourceLocation Loc, + void PrintIncludeStack(DiagnosticsEngine::Level Level, SourceLocation Loc, const SourceManager &SM); - void HighlightRange(const CharSourceRange &R, - const SourceManager &SrcMgr, - unsigned LineNo, FileID FID, - std::string &CaretLine, - const std::string &SourceLine); + virtual void HandleDiagnostic(DiagnosticsEngine::Level Level, + const Diagnostic &Info); - virtual void HandleDiagnostic(Diagnostic::Level Level, - const DiagnosticInfo &Info); + DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const; private: - void EmitCaretDiagnostic(SourceLocation Loc, CharSourceRange *Ranges, - unsigned NumRanges, const SourceManager &SM, - const FixItHint *Hints, - unsigned NumHints, unsigned Columns, - unsigned OnMacroInst, unsigned MacroSkipStart, - unsigned MacroSkipEnd); - + void EmitDiagnosticLoc(DiagnosticsEngine::Level Level, + const Diagnostic &Info, + const SourceManager &SM, + PresumedLoc PLoc); }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h index 93d2c7d..929beb0 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h @@ -31,7 +31,7 @@ class CompilerInstance; class CompilerInvocation; class Decl; class DependencyOutputOptions; -class Diagnostic; +class DiagnosticsEngine; class DiagnosticOptions; class FileManager; class HeaderSearch; @@ -48,7 +48,7 @@ class FrontendOptions; /// Normalize \arg File for use in a user defined #include directive (in the /// predefines buffer). -std::string NormalizeDashIncludePath(llvm::StringRef File, +std::string NormalizeDashIncludePath(StringRef File, FileManager &FileMgr); /// Apply the header search options to get given HeaderSearch object. @@ -66,10 +66,10 @@ void InitializePreprocessor(Preprocessor &PP, /// ProcessWarningOptions - Initialize the diagnostic client and process the /// warning options specified on the command line. -void ProcessWarningOptions(Diagnostic &Diags, const DiagnosticOptions &Opts); +void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts); /// DoPrintPreprocessedInput - Implement -E mode. -void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS, +void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS, const PreprocessorOutputOptions &Opts); /// AttachDependencyFileGen - Create a dependency file generator, and attach @@ -87,7 +87,7 @@ void AttachDependencyFileGen(Preprocessor &PP, /// \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 = "", + StringRef OutputPath = "", bool ShowDepth = true); /// CacheTokens - Cache tokens for use with PCH. Note that this requires @@ -100,9 +100,9 @@ void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); /// \return A CompilerInvocation, or 0 if none was built for the given /// argument vector. CompilerInvocation * -createInvocationFromCommandLine(llvm::ArrayRef<const char *> Args, - llvm::IntrusiveRefCntPtr<Diagnostic> Diags = - llvm::IntrusiveRefCntPtr<Diagnostic>()); +createInvocationFromCommandLine(ArrayRef<const char *> Args, + llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags = + llvm::IntrusiveRefCntPtr<DiagnosticsEngine>()); } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticsClient.h b/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h index 793cedd..28dc9de 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticsClient.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -1,4 +1,4 @@ -//===-- VerifyDiagnosticsClient.h - Verifying Diagnostic Client -*- C++ -*-===// +//===- VerifyDiagnosticConsumer.h - Verifying Diagnostic Client -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,12 +15,12 @@ namespace clang { -class Diagnostic; +class DiagnosticsEngine; 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. +/// VerifyDiagnosticConsumer - 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: /// @@ -62,31 +62,34 @@ class TextDiagnosticBuffer; /// // expected-error-re {{variable has has type 'struct (.*)'}} /// // expected-error-re {{variable has has type 'struct[[:space:]](.*)'}} /// -class VerifyDiagnosticsClient : public DiagnosticClient { +class VerifyDiagnosticConsumer: public DiagnosticConsumer { public: - Diagnostic &Diags; - llvm::OwningPtr<DiagnosticClient> PrimaryClient; + DiagnosticsEngine &Diags; + DiagnosticConsumer *PrimaryClient; + bool OwnsPrimaryClient; llvm::OwningPtr<TextDiagnosticBuffer> Buffer; Preprocessor *CurrentPreprocessor; private: + FileID FirstErrorFID; // FileID of first diagnostic 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(); + /// the currently-attached diagnostic client when a diagnostic does not match + /// what is expected (as indicated in the source file). + VerifyDiagnosticConsumer(DiagnosticsEngine &Diags); + ~VerifyDiagnosticConsumer(); virtual void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP); virtual void EndSourceFile(); - virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, - const DiagnosticInfo &Info); + virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info); + + virtual DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const; }; } // end namspace clang |