diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Frontend')
24 files changed, 673 insertions, 472 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h index 43d77f0..42dc69a 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h @@ -27,12 +27,13 @@ #include "clang/Sema/CodeCompleteConsumer.h" #include "clang/Serialization/ASTBitCodes.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Support/MD5.h" #include "llvm/Support/Path.h" #include <cassert> #include <map> +#include <memory> #include <string> #include <sys/types.h> #include <utility> @@ -63,33 +64,51 @@ class ASTDeserializationListener; /// \brief Utility class for loading a ASTContext from an AST file. /// class ASTUnit : public ModuleLoader { +public: + struct StandaloneFixIt { + std::pair<unsigned, unsigned> RemoveRange; + std::pair<unsigned, unsigned> InsertFromRange; + std::string CodeToInsert; + bool BeforePreviousInsertions; + }; + + struct StandaloneDiagnostic { + unsigned ID; + DiagnosticsEngine::Level Level; + std::string Message; + std::string Filename; + unsigned LocOffset; + std::vector<std::pair<unsigned, unsigned> > Ranges; + std::vector<StandaloneFixIt> FixIts; + }; + private: - IntrusiveRefCntPtr<LangOptions> LangOpts; + std::shared_ptr<LangOptions> LangOpts; IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; IntrusiveRefCntPtr<FileManager> FileMgr; IntrusiveRefCntPtr<SourceManager> SourceMgr; - OwningPtr<HeaderSearch> HeaderInfo; + std::unique_ptr<HeaderSearch> HeaderInfo; IntrusiveRefCntPtr<TargetInfo> Target; IntrusiveRefCntPtr<Preprocessor> PP; IntrusiveRefCntPtr<ASTContext> Ctx; - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts; - ASTReader *Reader; + IntrusiveRefCntPtr<ASTReader> Reader; bool HadModuleLoaderFatalFailure; struct ASTWriterData; - OwningPtr<ASTWriterData> WriterData; + std::unique_ptr<ASTWriterData> WriterData; FileSystemOptions FileSystemOpts; /// \brief The AST consumer that received information about the translation /// unit as it was parsed or loaded. - OwningPtr<ASTConsumer> Consumer; - + std::unique_ptr<ASTConsumer> Consumer; + /// \brief The semantic analysis object used to type-check the translation /// unit. - OwningPtr<Sema> TheSema; - + std::unique_ptr<Sema> TheSema; + /// Optional owned invocation, just used to make the invocation used in /// LoadFromCommandLine available. IntrusiveRefCntPtr<CompilerInvocation> Invocation; @@ -135,7 +154,7 @@ private: std::string OriginalSourceFile; /// \brief The set of diagnostics produced when creating the preamble. - SmallVector<StoredDiagnostic, 4> PreambleDiagnostics; + SmallVector<StandaloneDiagnostic, 4> PreambleDiagnostics; /// \brief The set of diagnostics produced when creating this /// translation unit. @@ -170,7 +189,7 @@ public: mutable unsigned NumLines; public: - PreambleData() : File(0), NumLines(0) { } + PreambleData() : File(nullptr), NumLines(0) { } void assign(const FileEntry *F, const char *begin, const char *end) { File = F; @@ -178,7 +197,7 @@ public: NumLines = 0; } - void clear() { Buffer.clear(); File = 0; NumLines = 0; } + void clear() { Buffer.clear(); File = nullptr; NumLines = 0; } size_t size() const { return Buffer.size(); } bool empty() const { return Buffer.empty(); } @@ -205,8 +224,34 @@ public: return Preamble; } -private: + /// Data used to determine if a file used in the preamble has been changed. + struct PreambleFileHash { + /// All files have size set. + off_t Size; + + /// Modification time is set for files that are on disk. For memory + /// buffers it is zero. + time_t ModTime; + + /// Memory buffers have MD5 instead of modification time. We don't + /// compute MD5 for on-disk files because we hope that modification time is + /// enough to tell if the file was changed. + llvm::MD5::MD5Result MD5; + static PreambleFileHash createForFile(off_t Size, time_t ModTime); + static PreambleFileHash + createForMemoryBuffer(const llvm::MemoryBuffer *Buffer); + + friend bool operator==(const PreambleFileHash &LHS, + const PreambleFileHash &RHS); + + friend bool operator!=(const PreambleFileHash &LHS, + const PreambleFileHash &RHS) { + return !(LHS == RHS); + } + }; + +private: /// \brief The contents of the preamble that has been precompiled to /// \c PreambleFile. PreambleData Preamble; @@ -216,17 +261,13 @@ private: /// 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; + llvm::StringMap<PreambleFileHash> 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 @@ -268,9 +309,9 @@ private: const char **ArgBegin, const char **ArgEnd, ASTUnit &AST, bool CaptureDiagnostics); - void TranslateStoredDiagnostics(ASTReader *MMan, StringRef ModName, + void TranslateStoredDiagnostics(FileManager &FileMgr, SourceManager &SrcMan, - const SmallVectorImpl<StoredDiagnostic> &Diags, + const SmallVectorImpl<StandaloneDiagnostic> &Diags, SmallVectorImpl<StoredDiagnostic> &Out); void clearFileLevelDecls(); @@ -337,8 +378,8 @@ private: /// \brief Allocator used to store cached code completions. IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> CachedCompletionAllocator; - - OwningPtr<CodeCompletionTUInfo> CCTUInfo; + + std::unique_ptr<CodeCompletionTUInfo> CCTUInfo; /// \brief The set of cached code-completion results. std::vector<CachedCodeCompletionResult> CachedCompletionResults; @@ -406,9 +447,7 @@ private: /// just about any usage. /// Becomes a noop in release mode; only useful for debug mode checking. class ConcurrencyState { -#ifndef NDEBUG void *Mutex; // a llvm::sys::MutexImpl in debug; -#endif public: ConcurrencyState(); @@ -457,10 +496,15 @@ public: void setASTContext(ASTContext *ctx) { Ctx = ctx; } void setPreprocessor(Preprocessor *pp); - bool hasSema() const { return TheSema.isValid(); } + bool hasSema() const { return (bool)TheSema; } Sema &getSema() const { assert(TheSema && "ASTUnit does not have a Sema object!"); - return *TheSema; + return *TheSema; + } + + const LangOptions &getLangOpts() const { + assert(LangOpts && " ASTUnit does not have language options"); + return *LangOpts; } const FileManager &getFileManager() const { return *FileMgr; } @@ -641,16 +685,14 @@ public: bool isModuleFile(); llvm::MemoryBuffer *getBufferForFile(StringRef Filename, - std::string *ErrorStr = 0); + std::string *ErrorStr = nullptr); /// \brief Determine what kind of translation unit this AST represents. TranslationUnitKind getTranslationUnitKind() const { return TUKind; } - typedef llvm::PointerUnion<const char *, const llvm::MemoryBuffer *> - FilenameOrMemBuf; /// \brief A mapping from a file name to the memory buffer that stores the /// remapped contents of that file. - typedef std::pair<std::string, FilenameOrMemBuf> RemappedFile; + typedef std::pair<std::string, llvm::MemoryBuffer *> RemappedFile; /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation. static ASTUnit *create(CompilerInvocation *CI, @@ -670,8 +712,7 @@ public: IntrusiveRefCntPtr<DiagnosticsEngine> Diags, const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls = false, - RemappedFile *RemappedFiles = 0, - unsigned NumRemappedFiles = 0, + ArrayRef<RemappedFile> RemappedFiles = None, bool CaptureDiagnostics = false, bool AllowPCHWithCompilerErrors = false, bool UserFilesAreVolatile = false); @@ -714,19 +755,15 @@ public: /// This will only receive an ASTUnit if a new one was created. If an already /// created ASTUnit was passed in \p Unit then the caller can check that. /// - static ASTUnit *LoadFromCompilerInvocationAction(CompilerInvocation *CI, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - ASTFrontendAction *Action = 0, - ASTUnit *Unit = 0, - bool Persistent = true, - StringRef ResourceFilesPath = StringRef(), - bool OnlyLocalDecls = false, - bool CaptureDiagnostics = false, - bool PrecompilePreamble = false, - bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false, - bool UserFilesAreVolatile = false, - OwningPtr<ASTUnit> *ErrAST = 0); + static ASTUnit *LoadFromCompilerInvocationAction( + CompilerInvocation *CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, + ASTFrontendAction *Action = nullptr, ASTUnit *Unit = nullptr, + bool Persistent = true, StringRef ResourceFilesPath = StringRef(), + bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, + bool PrecompilePreamble = false, bool CacheCodeCompletionResults = false, + bool IncludeBriefCommentsInCodeCompletion = false, + bool UserFilesAreVolatile = false, + std::unique_ptr<ASTUnit> *ErrAST = nullptr); /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a /// CompilerInvocation object. @@ -739,15 +776,13 @@ 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, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - bool OnlyLocalDecls = false, - bool CaptureDiagnostics = false, - bool PrecompilePreamble = false, - TranslationUnitKind TUKind = TU_Complete, - bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false, - bool UserFilesAreVolatile = false); + static std::unique_ptr<ASTUnit> LoadFromCompilerInvocation( + CompilerInvocation *CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, + bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, + bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete, + bool CacheCodeCompletionResults = false, + bool IncludeBriefCommentsInCodeCompletion = false, + bool UserFilesAreVolatile = false); /// LoadFromCommandLine - Create an ASTUnit from a vector of command line /// arguments, which must specify exactly one source file. @@ -767,32 +802,25 @@ public: /// // 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, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - StringRef ResourceFilesPath, - bool OnlyLocalDecls = false, - bool CaptureDiagnostics = false, - RemappedFile *RemappedFiles = 0, - unsigned NumRemappedFiles = 0, - bool RemappedFilesKeepOriginalName = true, - bool PrecompilePreamble = false, - TranslationUnitKind TUKind = TU_Complete, - bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false, - bool AllowPCHWithCompilerErrors = false, - bool SkipFunctionBodies = false, - bool UserFilesAreVolatile = false, - bool ForSerialization = false, - OwningPtr<ASTUnit> *ErrAST = 0); - + static ASTUnit *LoadFromCommandLine( + const char **ArgBegin, const char **ArgEnd, + IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath, + bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, + ArrayRef<RemappedFile> RemappedFiles = None, + bool RemappedFilesKeepOriginalName = true, + bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete, + bool CacheCodeCompletionResults = false, + bool IncludeBriefCommentsInCodeCompletion = false, + bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, + bool UserFilesAreVolatile = false, bool ForSerialization = false, + std::unique_ptr<ASTUnit> *ErrAST = nullptr); + /// \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); + bool Reparse(ArrayRef<RemappedFile> RemappedFiles = None); /// \brief Perform code completion at the given file, line, and /// column within this translation unit. @@ -815,7 +843,7 @@ public: /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and /// OwnedBuffers parameters are all disgusting hacks. They will go away. void CodeComplete(StringRef File, unsigned Line, unsigned Column, - RemappedFile *RemappedFiles, unsigned NumRemappedFiles, + ArrayRef<RemappedFile> RemappedFiles, bool IncludeMacros, bool IncludeCodePatterns, bool IncludeBriefComments, CodeCompleteConsumer &Consumer, @@ -834,20 +862,21 @@ public: /// /// \returns True if an error occurred, false otherwise. bool serialize(raw_ostream &OS); - - virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, - ModuleIdPath Path, - Module::NameVisibilityKind Visibility, - bool IsInclusionDirective) { + + ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, + Module::NameVisibilityKind Visibility, + bool IsInclusionDirective) override { // ASTUnit doesn't know how to load modules (not that this matters). return ModuleLoadResult(); } - virtual void makeModuleVisible(Module *Mod, - Module::NameVisibilityKind Visibility, - SourceLocation ImportLoc, - bool Complain) { } + void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, + SourceLocation ImportLoc, bool Complain) override {} + GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override + { return nullptr; } + bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override + { return 0; }; }; } // namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h index b7dc7c7..11762a9 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h @@ -11,7 +11,7 @@ #define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCONSUMER_H #include "clang/Basic/Diagnostic.h" -#include "llvm/ADT/OwningPtr.h" +#include <memory> namespace clang { class LangOptions; @@ -22,8 +22,8 @@ class LangOptions; /// diagnostics should be included in counts. class ChainedDiagnosticConsumer : public DiagnosticConsumer { virtual void anchor(); - OwningPtr<DiagnosticConsumer> Primary; - OwningPtr<DiagnosticConsumer> Secondary; + std::unique_ptr<DiagnosticConsumer> Primary; + std::unique_ptr<DiagnosticConsumer> Secondary; public: ChainedDiagnosticConsumer(DiagnosticConsumer *_Primary, @@ -32,28 +32,28 @@ public: Secondary.reset(_Secondary); } - virtual void BeginSourceFile(const LangOptions &LO, - const Preprocessor *PP) { + void BeginSourceFile(const LangOptions &LO, + const Preprocessor *PP) override { Primary->BeginSourceFile(LO, PP); Secondary->BeginSourceFile(LO, PP); } - virtual void EndSourceFile() { + void EndSourceFile() override { Secondary->EndSourceFile(); Primary->EndSourceFile(); } - virtual void finish() { + void finish() override { Secondary->finish(); Primary->finish(); } - virtual bool IncludeInDiagnosticCounts() const { + bool IncludeInDiagnosticCounts() const override { return Primary->IncludeInDiagnosticCounts(); } - virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, - const Diagnostic &Info) { + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info) override { // Default implementation (Warnings/errors count). DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info); diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedIncludesSource.h b/contrib/llvm/tools/clang/include/clang/Frontend/ChainedIncludesSource.h deleted file mode 100644 index aa30460..0000000 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ChainedIncludesSource.h +++ /dev/null @@ -1,75 +0,0 @@ -//===- ChainedIncludesSource.h - Chained PCHs in Memory ---------*- 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 ChainedIncludesSource class, which converts headers -// to chained PCHs in memory, mainly used for testing. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_SERIALIZATION_CHAINEDINCLUDESSOURCE_H -#define LLVM_CLANG_SERIALIZATION_CHAINEDINCLUDESSOURCE_H - -#include "clang/Sema/ExternalSemaSource.h" -#include <vector> - -namespace clang { - class CompilerInstance; - -class ChainedIncludesSource : public ExternalSemaSource { -public: - virtual ~ChainedIncludesSource(); - - static ChainedIncludesSource *create(CompilerInstance &CI); - - ExternalSemaSource &getFinalReader() const { return *FinalReader; } - -private: - std::vector<CompilerInstance *> CIs; - OwningPtr<ExternalSemaSource> FinalReader; - - -protected: - -//===----------------------------------------------------------------------===// -// ExternalASTSource interface. -//===----------------------------------------------------------------------===// - - virtual Decl *GetExternalDecl(uint32_t ID); - virtual Selector GetExternalSelector(uint32_t ID); - virtual uint32_t GetNumExternalSelectors(); - virtual Stmt *GetExternalDeclStmt(uint64_t Offset); - virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); - virtual bool FindExternalVisibleDeclsByName(const DeclContext *DC, - DeclarationName Name); - virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, - bool (*isKindWeWant)(Decl::Kind), - SmallVectorImpl<Decl*> &Result); - virtual void CompleteType(TagDecl *Tag); - virtual void CompleteType(ObjCInterfaceDecl *Class); - virtual void StartedDeserializing(); - virtual void FinishedDeserializing(); - virtual void StartTranslationUnit(ASTConsumer *Consumer); - virtual void PrintStats(); - - /// Return the amount of memory used by memory buffers, breaking down - /// by heap-backed versus mmap'ed memory. - virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; - -//===----------------------------------------------------------------------===// -// ExternalSemaSource interface. -//===----------------------------------------------------------------------===// - - virtual void InitializeSema(Sema &S); - virtual void ForgetSema(); - virtual void ReadMethodPool(Selector Sel); - virtual bool LookupUnqualified(LookupResult &R, Scope *S); -}; - -} - -#endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def index 78b825d..1d92efe 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def @@ -28,6 +28,8 @@ CODEGENOPT(Name, Bits, Default) CODEGENOPT(Name, Bits, Default) #endif +CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as +CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm. CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe. @@ -59,8 +61,6 @@ ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On) CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard variables ///< are required. CODEGENOPT(FunctionSections , 1, 0) ///< Set when -ffunction-sections is enabled. -CODEGENOPT(HiddenWeakVTables , 1, 0) ///< Emit weak vtables, RTTI, and thunks with - ///< hidden visibility. CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is ///< enabled. CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled. @@ -68,7 +68,6 @@ CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions t ///< be generated. CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. -CODEGENOPT(NoDwarf2CFIAsm , 1, 0) ///< Set when -fno-dwarf2-cfi-asm is enabled. CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is ///< enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. @@ -87,6 +86,9 @@ CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer VALUE_CODEGENOPT(OptimizationLevel, 3, 0) ///< The -O[0-4] option specified. VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified. +CODEGENOPT(ProfileInstrGenerate , 1, 0) ///< Instrument code to generate + ///< execution counts to use with PGO. + /// If -fpcc-struct-return or -freg-struct-return is specified. ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, SRCK_Default) @@ -96,7 +98,7 @@ CODEGENOPT(StructPathTBAA , 1, 0) ///< Whether or not to use struct-path TBAA CODEGENOPT(SaveTempLabels , 1, 0) ///< Save temporary labels. CODEGENOPT(SanitizeAddressZeroBaseShadow , 1, 0) ///< Map shadow memory at zero ///< offset in AddressSanitizer. -CODEGENOPT(SanitizeMemoryTrackOrigins, 1, 0) ///< Enable tracking origins in +CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in ///< MemorySanitizer CODEGENOPT(SanitizeUndefinedTrapOnError, 1, 0) ///< Set on /// -fsanitize-undefined-trap-on-error @@ -138,7 +140,7 @@ VALUE_CODEGENOPT(NumRegisterParameters, 32, 0) VALUE_CODEGENOPT(SSPBufferSize, 32, 0) /// The kind of generated debug info. -ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 2, NoDebugInfo) +ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 3, NoDebugInfo) /// Dwarf version. VALUE_CODEGENOPT(DwarfVersion, 3, 0) diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h index 0d24697..3d532ce 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h @@ -16,6 +16,7 @@ #include <string> #include <vector> +#include "llvm/Support/Regex.h" namespace clang { @@ -52,6 +53,13 @@ public: enum DebugInfoKind { NoDebugInfo, /// Don't generate debug info. + LocTrackingOnly, /// Emit location information but do not generate + /// debug info in the output. This is useful in + /// cases where the backend wants to track source + /// locations for instructions without actually + /// emitting debug info for them (e.g., when -Rpass + /// is used). + DebugLineTablesOnly, /// Emit only debug info necessary for generating /// line number tables (-gline-tables-only). @@ -142,6 +150,31 @@ public: /// Name of the profile file to use with -fprofile-sample-use. std::string SampleProfileFile; + /// Name of the profile file to use as input for -fprofile-instr-use + std::string InstrProfileInput; + + /// Regular expression to select optimizations for which we should enable + /// optimization remarks. Transformation passes whose name matches this + /// expression (and support this feature), will emit a diagnostic + /// whenever they perform a transformation. This is enabled by the + /// -Rpass=regexp flag. + std::shared_ptr<llvm::Regex> OptimizationRemarkPattern; + + /// Regular expression to select optimizations for which we should enable + /// missed optimization remarks. Transformation passes whose name matches this + /// expression (and support this feature), will emit a diagnostic + /// whenever they tried but failed to perform a transformation. This is + /// enabled by the -Rpass-missed=regexp flag. + std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern; + + /// Regular expression to select optimizations for which we should enable + /// optimization analyses. Transformation passes whose name matches this + /// expression (and support this feature), will emit a diagnostic + /// whenever they want to explain why they decided to apply or not apply + /// a given transformation. This is enabled by the -Rpass-analysis=regexp + /// flag. + std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern; + public: // Define accessors/mutators for code generation options of enumeration type. #define CODEGENOPT(Name, Bits, Default) diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h index 5673c59..44e9102 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h @@ -13,14 +13,15 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Frontend/CompilerInvocation.h" +#include "clang/Frontend/Utils.h" #include "clang/Lex/ModuleLoader.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" #include <cassert> #include <list> +#include <memory> #include <string> #include <utility> @@ -74,6 +75,9 @@ class CompilerInstance : public ModuleLoader { /// The target being compiled for. IntrusiveRefCntPtr<TargetInfo> Target; + /// The virtual file system. + IntrusiveRefCntPtr<vfs::FileSystem> VirtualFileSystem; + /// The file manager. IntrusiveRefCntPtr<FileManager> FileMgr; @@ -87,19 +91,27 @@ class CompilerInstance : public ModuleLoader { IntrusiveRefCntPtr<ASTContext> Context; /// The AST consumer. - OwningPtr<ASTConsumer> Consumer; + std::unique_ptr<ASTConsumer> Consumer; /// The code completion consumer. - OwningPtr<CodeCompleteConsumer> CompletionConsumer; + std::unique_ptr<CodeCompleteConsumer> CompletionConsumer; /// \brief The semantic analysis object. - OwningPtr<Sema> TheSema; + std::unique_ptr<Sema> TheSema; /// \brief The frontend timer - OwningPtr<llvm::Timer> FrontendTimer; + std::unique_ptr<llvm::Timer> FrontendTimer; + + /// \brief The ASTReader, if one exists. + IntrusiveRefCntPtr<ASTReader> ModuleManager; + + /// \brief The module dependency collector for crashdumps + std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector; + + /// \brief The dependency file generator. + std::unique_ptr<DependencyFileGenerator> TheDependencyFileGenerator; - /// \brief Non-owning reference to the ASTReader, if one exists. - ASTReader *ModuleManager; + std::vector<std::shared_ptr<DependencyCollector>> DependencyCollectors; /// \brief The set of top-level modules that has already been loaded, /// along with the module map @@ -117,13 +129,16 @@ class CompilerInstance : public ModuleLoader { /// have finished with this translation unit. bool BuildGlobalModuleIndex; + /// \brief We have a full global module index, with all modules. + bool HaveFullGlobalModuleIndex; + /// \brief One or more modules failed to build. bool ModuleBuildFailed; /// \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 + /// TempFilename may be empty and Filename non-empty if creating the temporary /// failed. struct OutputFile { std::string Filename; @@ -141,7 +156,7 @@ class CompilerInstance : public ModuleLoader { CompilerInstance(const CompilerInstance &) LLVM_DELETED_FUNCTION; void operator=(const CompilerInstance &) LLVM_DELETED_FUNCTION; public: - CompilerInstance(); + explicit CompilerInstance(bool BuildingModule = false); ~CompilerInstance(); /// @name High-Level Operations @@ -183,7 +198,7 @@ public: /// @name Compiler Invocation and Options /// { - bool hasInvocation() const { return Invocation != 0; } + bool hasInvocation() const { return Invocation != nullptr; } CompilerInvocation &getInvocation() { assert(Invocation && "Compiler instance has no invocation!"); @@ -281,7 +296,7 @@ public: /// @name Diagnostics Engine /// { - bool hasDiagnostics() const { return Diagnostics != 0; } + bool hasDiagnostics() const { return Diagnostics != nullptr; } /// Get the current diagnostics engine. DiagnosticsEngine &getDiagnostics() const { @@ -302,7 +317,7 @@ public: /// @name Target Info /// { - bool hasTarget() const { return Target != 0; } + bool hasTarget() const { return Target != nullptr; } TargetInfo &getTarget() const { assert(Target && "Compiler instance has no target!"); @@ -313,10 +328,30 @@ public: void setTarget(TargetInfo *Value); /// } + /// @name Virtual File System + /// { + + bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; } + + vfs::FileSystem &getVirtualFileSystem() const { + assert(hasVirtualFileSystem() && + "Compiler instance has no virtual file system"); + return *VirtualFileSystem; + } + + /// \brief Replace the current virtual file system. + /// + /// \note Most clients should use setFileManager, which will implicitly reset + /// the virtual file system to the one contained in the file manager. + void setVirtualFileSystem(IntrusiveRefCntPtr<vfs::FileSystem> FS) { + VirtualFileSystem = FS; + } + + /// } /// @name File Manager /// { - bool hasFileManager() const { return FileMgr != 0; } + bool hasFileManager() const { return FileMgr != nullptr; } /// Return the current file manager to the caller. FileManager &getFileManager() const { @@ -325,17 +360,18 @@ public: } void resetAndLeakFileManager() { + BuryPointer(FileMgr.get()); FileMgr.resetWithoutRelease(); } - /// setFileManager - Replace the current file manager. + /// \brief Replace the current file manager and virtual file system. void setFileManager(FileManager *Value); /// } /// @name Source Manager /// { - bool hasSourceManager() const { return SourceMgr != 0; } + bool hasSourceManager() const { return SourceMgr != nullptr; } /// Return the current source manager. SourceManager &getSourceManager() const { @@ -344,6 +380,7 @@ public: } void resetAndLeakSourceManager() { + BuryPointer(SourceMgr.get()); SourceMgr.resetWithoutRelease(); } @@ -354,7 +391,7 @@ public: /// @name Preprocessor /// { - bool hasPreprocessor() const { return PP != 0; } + bool hasPreprocessor() const { return PP != nullptr; } /// Return the current preprocessor. Preprocessor &getPreprocessor() const { @@ -363,6 +400,7 @@ public: } void resetAndLeakPreprocessor() { + BuryPointer(PP.get()); PP.resetWithoutRelease(); } @@ -373,7 +411,7 @@ public: /// @name ASTContext /// { - bool hasASTContext() const { return Context != 0; } + bool hasASTContext() const { return Context != nullptr; } ASTContext &getASTContext() const { assert(Context && "Compiler instance has no AST context!"); @@ -381,6 +419,7 @@ public: } void resetAndLeakASTContext() { + BuryPointer(Context.get()); Context.resetWithoutRelease(); } @@ -395,7 +434,7 @@ public: /// @name ASTConsumer /// { - bool hasASTConsumer() const { return Consumer.isValid(); } + bool hasASTConsumer() const { return (bool)Consumer; } ASTConsumer &getASTConsumer() const { assert(Consumer && "Compiler instance has no AST consumer!"); @@ -404,7 +443,7 @@ public: /// takeASTConsumer - Remove the current AST consumer and give ownership to /// the caller. - ASTConsumer *takeASTConsumer() { return Consumer.take(); } + ASTConsumer *takeASTConsumer() { return Consumer.release(); } /// setASTConsumer - Replace the current AST consumer; the compiler instance /// takes ownership of \p Value. @@ -413,29 +452,32 @@ public: /// } /// @name Semantic analysis /// { - bool hasSema() const { return TheSema.isValid(); } - + bool hasSema() const { return (bool)TheSema; } + Sema &getSema() const { assert(TheSema && "Compiler instance has no Sema object!"); return *TheSema; } - - Sema *takeSema() { return TheSema.take(); } - + + Sema *takeSema() { return TheSema.release(); } + void resetAndLeakSema() { BuryPointer(TheSema.release()); } + /// } /// @name Module Management /// { - ASTReader *getModuleManager() const { return ModuleManager; } - void setModuleManager(ASTReader *Reader) { ModuleManager = Reader; } + IntrusiveRefCntPtr<ASTReader> getModuleManager() const; + void setModuleManager(IntrusiveRefCntPtr<ASTReader> Reader); + + std::shared_ptr<ModuleDependencyCollector> getModuleDepCollector() const; + void setModuleDepCollector( + std::shared_ptr<ModuleDependencyCollector> Collector); /// } /// @name Code Completion /// { - bool hasCodeCompletionConsumer() const { - return CompletionConsumer.isValid(); - } + bool hasCodeCompletionConsumer() const { return (bool)CompletionConsumer; } CodeCompleteConsumer &getCodeCompletionConsumer() const { assert(CompletionConsumer && @@ -446,7 +488,7 @@ public: /// takeCodeCompletionConsumer - Remove the current code completion consumer /// and give ownership to the caller. CodeCompleteConsumer *takeCodeCompletionConsumer() { - return CompletionConsumer.take(); + return CompletionConsumer.release(); } /// setCodeCompletionConsumer - Replace the current code completion consumer; @@ -457,7 +499,7 @@ public: /// @name Frontend timer /// { - bool hasFrontendTimer() const { return FrontendTimer.isValid(); } + bool hasFrontendTimer() const { return (bool)FrontendTimer; } llvm::Timer &getFrontendTimer() const { assert(FrontendTimer && "Compiler instance has no frontend timer!"); @@ -495,7 +537,7 @@ public: /// /// \param ShouldOwnClient If Client is non-NULL, specifies whether /// the diagnostic object should take ownership of the client. - void createDiagnostics(DiagnosticConsumer *Client = 0, + void createDiagnostics(DiagnosticConsumer *Client = nullptr, bool ShouldOwnClient = true); /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter. @@ -518,9 +560,9 @@ public: /// \return The new object on success, or null on failure. static IntrusiveRefCntPtr<DiagnosticsEngine> createDiagnostics(DiagnosticOptions *Opts, - DiagnosticConsumer *Client = 0, + DiagnosticConsumer *Client = nullptr, bool ShouldOwnClient = true, - const CodeGenOptions *CodeGenOpts = 0); + const CodeGenOptions *CodeGenOpts = nullptr); /// Create the file manager and replace any existing one with it. void createFileManager(); @@ -530,28 +572,26 @@ public: /// Create the preprocessor, using the invocation, file, and source managers, /// and replace any existing one with it. - void createPreprocessor(); + void createPreprocessor(TranslationUnitKind TUKind); /// 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(StringRef Path, - bool DisablePCHValidation, + void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, - void *DeserializationListener); + void *DeserializationListener, + bool OwnDeserializationListener); /// Create an external AST source to read a PCH file. /// /// \return - The new object on success, or null on failure. - static ExternalASTSource * - createPCHExternalASTSource(StringRef Path, const std::string &Sysroot, - bool DisablePCHValidation, - bool AllowPCHWithCompilerErrors, - Preprocessor &PP, ASTContext &Context, - void *DeserializationListener, bool Preamble, - bool UseGlobalModuleIndex); + static ExternalASTSource *createPCHExternalASTSource( + StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, + bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, + void *DeserializationListener, bool OwnDeserializationListener, + bool Preamble, bool UseGlobalModuleIndex); /// Create a code completion consumer using the invocation; note that this /// will cause the source manager to truncate the input source file at the @@ -632,6 +672,8 @@ public: std::string *ResultPathName, std::string *TempPathName); + llvm::raw_null_ostream *createNullOutputFile(); + /// } /// @name Initialization Utility Methods /// { @@ -653,21 +695,28 @@ public: const FrontendOptions &Opts); /// } - - virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, - ModuleIdPath Path, - Module::NameVisibilityKind Visibility, - bool IsInclusionDirective); - virtual void makeModuleVisible(Module *Mod, - Module::NameVisibilityKind Visibility, - SourceLocation ImportLoc, - bool Complain); + // Create module manager. + void createModuleManager(); + + ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, + Module::NameVisibilityKind Visibility, + bool IsInclusionDirective) override; + + void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, + SourceLocation ImportLoc, bool Complain) override; bool hadModuleLoaderFatalFailure() const { return ModuleLoader::HadFatalFailure; } + GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override; + + bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override; + + void addDependencyCollector(std::shared_ptr<DependencyCollector> Listener) { + DependencyCollectors.push_back(std::move(Listener)); + } }; } // 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 f64773c..f05ab80 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h @@ -47,15 +47,17 @@ class DiagnosticsEngine; /// When errors are encountered, return false and, if Diags is non-null, /// report the error(s). bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args, - DiagnosticsEngine *Diags = 0); + DiagnosticsEngine *Diags = nullptr); class CompilerInvocationBase : public RefCountedBase<CompilerInvocation> { -protected: + void operator=(const CompilerInvocationBase &) LLVM_DELETED_FUNCTION; + +public: /// Options controlling the language variant. - IntrusiveRefCntPtr<LangOptions> LangOpts; + std::shared_ptr<LangOptions> LangOpts; /// Options controlling the target. - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; /// Options controlling the diagnostic engine. IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts; @@ -66,17 +68,17 @@ protected: /// Options controlling the preprocessor (aside from \#include handling). IntrusiveRefCntPtr<PreprocessorOptions> PreprocessorOpts; -public: CompilerInvocationBase(); + ~CompilerInvocationBase(); CompilerInvocationBase(const CompilerInvocationBase &X); - LangOptions *getLangOpts() { return LangOpts.getPtr(); } - const LangOptions *getLangOpts() const { return LangOpts.getPtr(); } + LangOptions *getLangOpts() { return LangOpts.get(); } + const LangOptions *getLangOpts() const { return LangOpts.get(); } - TargetOptions &getTargetOpts() { return *TargetOpts.getPtr(); } + TargetOptions &getTargetOpts() { return *TargetOpts.get(); } const TargetOptions &getTargetOpts() const { - return *TargetOpts.getPtr(); + return *TargetOpts.get(); } DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; } @@ -204,6 +206,14 @@ public: /// @} }; +namespace vfs { + class FileSystem; +} + +IntrusiveRefCntPtr<vfs::FileSystem> +createVFSFromCompilerInvocation(const CompilerInvocation &CI, + DiagnosticsEngine &Diags); + } // end namespace clang #endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h index fefb6f3..5da1459 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DependencyOutputOptions.h @@ -26,6 +26,7 @@ public: /// problems. unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info. + unsigned IncludeModuleFiles : 1; ///< Include module file dependencies. /// The file to write dependency output to. std::string OutputFile; @@ -42,7 +43,10 @@ public: /// \brief The file to write GraphViz-formatted header dependencies to. std::string DOTOutputFile; - + + /// \brief The directory to copy module dependencies to when collecting them. + std::string ModuleDependencyOutputDir; + public: DependencyOutputOptions() { IncludeSystemHeaders = 0; @@ -50,6 +54,7 @@ public: UsePhonyTargets = 0; AddMissingHeaderDeps = 0; PrintShowIncludes = 0; + IncludeModuleFiles = 0; } }; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h index f3cd054..ce1dc90 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h @@ -83,9 +83,7 @@ protected: DiagnosticsEngine::Level Level, ArrayRef<CharSourceRange> Ranges, const SourceManager &SM) = 0; - - virtual void emitBasicNote(StringRef Message) = 0; - + virtual void emitCodeContext(SourceLocation Loc, DiagnosticsEngine::Level Level, SmallVectorImpl<CharSourceRange>& Ranges, @@ -108,6 +106,7 @@ protected: private: + void emitBasicNote(StringRef Message); void emitIncludeStack(SourceLocation Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level, const SourceManager &SM); void emitIncludeStackRecursively(SourceLocation Loc, const SourceManager &SM); @@ -144,7 +143,7 @@ public: StringRef Message, ArrayRef<CharSourceRange> Ranges, ArrayRef<FixItHint> FixItHints, const SourceManager *SM, - DiagOrStoredDiag D = (Diagnostic *)0); + DiagOrStoredDiag D = (Diagnostic *)nullptr); void emitStoredDiagnostic(StoredDiagnostic &Diag); }; @@ -158,20 +157,17 @@ public: : DiagnosticRenderer(LangOpts, DiagOpts) {} virtual ~DiagnosticNoteRenderer(); - - virtual void emitBasicNote(StringRef Message); - - virtual void emitIncludeLocation(SourceLocation Loc, - PresumedLoc PLoc, - const SourceManager &SM); - virtual void emitImportLocation(SourceLocation Loc, PresumedLoc PLoc, - StringRef ModuleName, - const SourceManager &SM); + void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, + const SourceManager &SM) override; - virtual void emitBuildingModuleLocation(SourceLocation Loc, PresumedLoc PLoc, - StringRef ModuleName, - const SourceManager &SM); + void emitImportLocation(SourceLocation Loc, PresumedLoc PLoc, + StringRef ModuleName, + const SourceManager &SM) override; + + void emitBuildingModuleLocation(SourceLocation Loc, PresumedLoc PLoc, + StringRef ModuleName, + const SourceManager &SM) override; virtual void emitNote(SourceLocation Loc, StringRef Message, const SourceManager *SM) = 0; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h index a568ba0..9ac9d28 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendAction.h @@ -21,8 +21,8 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" #include "clang/Frontend/FrontendOptions.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" +#include <memory> #include <string> #include <vector> @@ -35,7 +35,7 @@ class CompilerInstance; /// Abstract base class for actions which can be performed by the frontend. class FrontendAction { FrontendInputFile CurrentInput; - OwningPtr<ASTUnit> CurrentASTUnit; + std::unique_ptr<ASTUnit> CurrentASTUnit; CompilerInstance *Instance; friend class ASTMergeAction; friend class WrapperFrontendAction; @@ -124,7 +124,7 @@ public: bool isCurrentFileAST() const { assert(!CurrentInput.isEmpty() && "No current file!"); - return CurrentASTUnit.isValid(); + return (bool)CurrentASTUnit; } const FrontendInputFile &getCurrentInput() const { @@ -146,11 +146,10 @@ public: return *CurrentASTUnit; } - ASTUnit *takeCurrentASTUnit() { - return CurrentASTUnit.take(); - } + ASTUnit *takeCurrentASTUnit() { return CurrentASTUnit.release(); } - void setCurrentInput(const FrontendInputFile &CurrentInput, ASTUnit *AST = 0); + void setCurrentInput(const FrontendInputFile &CurrentInput, + ASTUnit *AST = nullptr); /// @} /// @name Supported Modes @@ -220,17 +219,17 @@ protected: /// /// This will also take care of instantiating a code completion consumer if /// the user requested it and the action supports it. - virtual void ExecuteAction(); + void ExecuteAction() override; public: - virtual bool usesPreprocessorOnly() const { return false; } + bool usesPreprocessorOnly() const override { return false; } }; class PluginASTAction : public ASTFrontendAction { virtual void anchor(); protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) = 0; + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override = 0; public: /// \brief Parse the given plugin command line arguments. @@ -248,11 +247,11 @@ class PreprocessorFrontendAction : public FrontendAction { protected: /// \brief Provide a default implementation which returns aborts; /// this method should never be called by FrontendAction clients. - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; public: - virtual bool usesPreprocessorOnly() const { return true; } + bool usesPreprocessorOnly() const override { return true; } }; /// \brief A frontend action which simply wraps some other runtime-specified @@ -262,28 +261,27 @@ public: /// some existing action's behavior. It implements every virtual method in /// the FrontendAction interface by forwarding to the wrapped action. class WrapperFrontendAction : public FrontendAction { - OwningPtr<FrontendAction> WrappedAction; + std::unique_ptr<FrontendAction> WrappedAction; protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); - virtual bool BeginInvocation(CompilerInstance &CI); - virtual bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename); - virtual void ExecuteAction(); - virtual void EndSourceFileAction(); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; + bool BeginInvocation(CompilerInstance &CI) override; + bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + void ExecuteAction() override; + void EndSourceFileAction() override; public: /// Construct a WrapperFrontendAction from an existing action, taking /// ownership of it. WrapperFrontendAction(FrontendAction *WrappedAction); - virtual bool usesPreprocessorOnly() const; - virtual TranslationUnitKind getTranslationUnitKind(); - virtual bool hasPCHSupport() const; - virtual bool hasASTFileSupport() const; - virtual bool hasIRSupport() const; - virtual bool hasCodeCompletionSupport() const; + bool usesPreprocessorOnly() const override; + TranslationUnitKind getTranslationUnitKind() override; + bool hasPCHSupport() const override; + bool hasASTFileSupport() const override; + bool hasIRSupport() const override; + bool hasCodeCompletionSupport() const override; }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h index f3d1276..84cc82c 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h @@ -17,21 +17,22 @@ namespace clang { class Module; +class FileEntry; //===----------------------------------------------------------------------===// // Custom Consumer Actions //===----------------------------------------------------------------------===// class InitOnlyAction : public FrontendAction { - virtual void ExecuteAction(); + void ExecuteAction() override; - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; 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; } + bool usesPreprocessorOnly() const override { return false; } }; //===----------------------------------------------------------------------===// @@ -40,44 +41,44 @@ public: class ASTPrintAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; }; class ASTDumpAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; }; class ASTDeclListAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; }; class ASTViewAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; }; class DeclContextPrintAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; }; class GeneratePCHAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; - virtual TranslationUnitKind getTranslationUnitKind() { + TranslationUnitKind getTranslationUnitKind() override { return TU_Prefix; } - virtual bool hasASTFileSupport() const { return false; } + bool hasASTFileSupport() const override { return false; } public: /// \brief Compute the AST consumer arguments that will be used to @@ -93,57 +94,71 @@ public: class GenerateModuleAction : public ASTFrontendAction { clang::Module *Module; + const FileEntry *ModuleMapForUniquing; bool IsSystem; protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); - - virtual TranslationUnitKind getTranslationUnitKind() { + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; + + TranslationUnitKind getTranslationUnitKind() override { return TU_Module; } - - virtual bool hasASTFileSupport() const { return false; } - + + bool hasASTFileSupport() const override { return false; } + public: - explicit GenerateModuleAction(bool IsSystem = false) - : ASTFrontendAction(), IsSystem(IsSystem) { } + GenerateModuleAction(const FileEntry *ModuleMap = nullptr, + bool IsSystem = false) + : ASTFrontendAction(), ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem) + { } + + bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; - virtual bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename); - /// \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, - StringRef InFile, - std::string &Sysroot, - std::string &OutputFile, - raw_ostream *&OS); + bool ComputeASTConsumerArguments(CompilerInstance &CI, + StringRef InFile, + std::string &Sysroot, + std::string &OutputFile, + raw_ostream *&OS); }; class SyntaxOnlyAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; public: - virtual bool hasCodeCompletionSupport() const { return true; } + bool hasCodeCompletionSupport() const override { return true; } }; /// \brief Dump information about the given module file, to be used for /// basic debugging and discovery. class DumpModuleInfoAction : public ASTFrontendAction { protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); - virtual void ExecuteAction(); - + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; + void ExecuteAction() override; + public: - virtual bool hasPCHSupport() const { return false; } - virtual bool hasASTFileSupport() const { return true; } - virtual bool hasIRSupport() const { return false; } - virtual bool hasCodeCompletionSupport() const { return false; } + bool hasPCHSupport() const override { return false; } + bool hasASTFileSupport() const override { return true; } + bool hasIRSupport() const override { return false; } + bool hasCodeCompletionSupport() const override { return false; } +}; + +class VerifyPCHAction : public ASTFrontendAction { +protected: + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; + + void ExecuteAction() override; + +public: + bool hasCodeCompletionSupport() const override { return false; } }; /** @@ -162,34 +177,34 @@ class ASTMergeAction : public FrontendAction { std::vector<std::string> ASTFiles; protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); + ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; - virtual bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename); + bool BeginSourceFileAction(CompilerInstance &CI, + StringRef Filename) override; - virtual void ExecuteAction(); - virtual void EndSourceFileAction(); + void ExecuteAction() override; + void EndSourceFileAction() override; public: ASTMergeAction(FrontendAction *AdaptedAction, ArrayRef<std::string> ASTFiles); virtual ~ASTMergeAction(); - virtual bool usesPreprocessorOnly() const; - virtual TranslationUnitKind getTranslationUnitKind(); - virtual bool hasPCHSupport() const; - virtual bool hasASTFileSupport() const; - virtual bool hasCodeCompletionSupport() const; + bool usesPreprocessorOnly() const override; + TranslationUnitKind getTranslationUnitKind() override; + bool hasPCHSupport() const override; + bool hasASTFileSupport() const override; + bool hasCodeCompletionSupport() const override; }; class PrintPreambleAction : public FrontendAction { protected: - void ExecuteAction(); - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef) { - return 0; + void ExecuteAction() override; + ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef) override { + return nullptr; } - - virtual bool usesPreprocessorOnly() const { return true; } + + bool usesPreprocessorOnly() const override { return true; } }; //===----------------------------------------------------------------------===// @@ -198,29 +213,29 @@ protected: class DumpRawTokensAction : public PreprocessorFrontendAction { protected: - void ExecuteAction(); + void ExecuteAction() override; }; class DumpTokensAction : public PreprocessorFrontendAction { protected: - void ExecuteAction(); + void ExecuteAction() override; }; class GeneratePTHAction : public PreprocessorFrontendAction { protected: - void ExecuteAction(); + void ExecuteAction() override; }; class PreprocessOnlyAction : public PreprocessorFrontendAction { protected: - void ExecuteAction(); + void ExecuteAction() override; }; class PrintPreprocessedAction : public PreprocessorFrontendAction { protected: - void ExecuteAction(); + void ExecuteAction() override; - virtual bool hasPCHSupport() const { return true; } + bool hasPCHSupport() const override { return true; } }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h index 4b321e8..e87da8d 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h @@ -43,6 +43,7 @@ namespace frontend { GeneratePTH, ///< Generate pre-tokenized header. InitOnly, ///< Only execute frontend initialization. ModuleFileInfo, ///< Dump information about a module file. + VerifyPCH, ///< Load and verify that a PCH file is usable. ParseSyntaxOnly, ///< Parse and perform semantic analysis. PluginAction, ///< Run a plugin action, \see ActionName. PrintDeclContext, ///< Print DeclContext and their Decls. @@ -89,9 +90,9 @@ class FrontendInputFile { bool IsSystem; public: - FrontendInputFile() : Buffer(0), Kind(IK_None) { } + FrontendInputFile() : Buffer(nullptr), Kind(IK_None) { } FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false) - : File(File.str()), Buffer(0), Kind(Kind), IsSystem(IsSystem) { } + : File(File.str()), Buffer(nullptr), Kind(Kind), IsSystem(IsSystem) { } FrontendInputFile(llvm::MemoryBuffer *buffer, InputKind Kind, bool IsSystem = false) : Buffer(buffer), Kind(Kind), IsSystem(IsSystem) { } @@ -99,9 +100,9 @@ public: InputKind getKind() const { return Kind; } bool isSystem() const { return IsSystem; } - bool isEmpty() const { return File.empty() && Buffer == 0; } + bool isEmpty() const { return File.empty() && Buffer == nullptr; } bool isFile() const { return !isBuffer(); } - bool isBuffer() const { return Buffer != 0; } + bool isBuffer() const { return Buffer != nullptr; } StringRef getFile() const { assert(isFile()); @@ -179,10 +180,13 @@ public: ObjCMT_ReturnsInnerPointerProperty = 0x200, /// \brief use NS_NONATOMIC_IOSONLY for property 'atomic' attribute ObjCMT_NsAtomicIOSOnlyProperty = 0x400, + /// \brief Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods. + ObjCMT_DesignatedInitializer = 0x800, ObjCMT_MigrateDecls = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty | ObjCMT_Annotation | ObjCMT_Instancetype | ObjCMT_NsMacros | ObjCMT_ProtocolConformance | - ObjCMT_NsAtomicIOSOnlyProperty), + ObjCMT_NsAtomicIOSOnlyProperty | + ObjCMT_DesignatedInitializer), ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting | ObjCMT_MigrateDecls) }; unsigned ObjCMTAction; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h index ec925ad..49be495 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h @@ -13,6 +13,9 @@ #include "clang/Frontend/FrontendAction.h" #include "llvm/Support/Registry.h" +// Instantiated in FrontendAction.cpp. +extern template class llvm::Registry<clang::PluginASTAction>; + namespace clang { /// The frontend plugin registry. diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h index 1124d53..9680e1f 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h @@ -25,10 +25,11 @@ enum LangFeatures { CPlusPlus = (1 << 4), CPlusPlus11 = (1 << 5), CPlusPlus1y = (1 << 6), - Digraphs = (1 << 7), - GNUMode = (1 << 8), - HexFloat = (1 << 9), - ImplicitInt = (1 << 10) + CPlusPlus1z = (1 << 7), + Digraphs = (1 << 8), + GNUMode = (1 << 9), + HexFloat = (1 << 10), + ImplicitInt = (1 << 11) }; } @@ -69,12 +70,15 @@ public: /// isCPlusPlus - Language is a C++ variant. bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } - /// isCPlusPlus11 - Language is a C++0x variant. + /// isCPlusPlus11 - Language is a C++11 variant (or later). bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; } - /// isCPlusPlus1y - Language is a C++1y variant. + /// isCPlusPlus1y - Language is a C++14 variant (or later). bool isCPlusPlus1y() const { return Flags & frontend::CPlusPlus1y; } + /// isCPlusPlus1z - Language is a C++17 variant (or later). + bool isCPlusPlus1z() const { return Flags & frontend::CPlusPlus1z; } + /// hasDigraphs - Language supports digraphs. bool hasDigraphs() const { return Flags & frontend::Digraphs; } diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def index 7b2516b..90a27b5 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def @@ -108,13 +108,29 @@ LANGSTANDARD(gnucxx11, "gnu++11", LineComment | CPlusPlus | CPlusPlus11 | Digraphs | GNUMode) LANGSTANDARD(cxx1y, "c++1y", - "Working draft for ISO C++ 2014", + "ISO C++ 2014 with amendments", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus1y | Digraphs) +LANGSTANDARD(cxx14, "c++14", + "ISO C++ 2014 with amendments", LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus1y | Digraphs) LANGSTANDARD(gnucxx1y, "gnu++1y", - "Working draft for ISO C++ 2014 with GNU extensions", + "ISO C++ 2014 with amendments and GNU extensions", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus1y | Digraphs | + GNUMode) +LANGSTANDARD(gnucxx14, "gnu++14", + "ISO C++ 2014 with amendments and GNU extensions", LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus1y | Digraphs | GNUMode) +LANGSTANDARD(cxx1z, "c++1z", + "Working draft for ISO C++ 2017", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus1y | CPlusPlus1z | + Digraphs) +LANGSTANDARD(gnucxx1z, "gnu++1z", + "Working draft for ISO C++ 2017 with GNU extensions", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus1y | CPlusPlus1z | + Digraphs | GNUMode) + // OpenCL LANGSTANDARD(opencl, "cl", "OpenCL 1.0", diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LayoutOverrideSource.h b/contrib/llvm/tools/clang/include/clang/Frontend/LayoutOverrideSource.h index ec34e14..16d032b 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LayoutOverrideSource.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LayoutOverrideSource.h @@ -47,12 +47,13 @@ namespace clang { /// \brief If this particular record type has an overridden layout, /// return that layout. - virtual bool + bool layoutRecordType(const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, - llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets); + llvm::DenseMap<const CXXRecordDecl *, + CharUnits> &VirtualBaseOffsets) override; /// \brief Dump the overridden layouts. void dump(); diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h b/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h index e8a6bb3..0130319 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LogDiagnosticPrinter.h @@ -39,7 +39,10 @@ class LogDiagnosticPrinter : public DiagnosticConsumer { /// The level of the diagnostic. DiagnosticsEngine::Level DiagnosticLevel; }; - + + void EmitDiagEntry(llvm::raw_ostream &OS, + const LogDiagnosticPrinter::DiagEntry &DE); + raw_ostream &OS; const LangOptions *LangOpts; IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; @@ -62,14 +65,14 @@ public: DwarfDebugFlags = Value; } - void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) { + void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override { LangOpts = &LO; } - void EndSourceFile(); + void EndSourceFile() override; - virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, - const Diagnostic &Info); + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info) override; }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h b/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h index 6ea7547..4d31104 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/MultiplexConsumer.h @@ -17,7 +17,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Sema/SemaConsumer.h" -#include "llvm/ADT/OwningPtr.h" +#include <memory> #include <vector> namespace clang { @@ -33,28 +33,35 @@ public: ~MultiplexConsumer(); // ASTConsumer - virtual void Initialize(ASTContext &Context); - virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); - virtual bool HandleTopLevelDecl(DeclGroupRef D); - virtual void HandleInterestingDecl(DeclGroupRef D); - virtual void HandleTranslationUnit(ASTContext &Ctx); - virtual void HandleTagDeclDefinition(TagDecl *D); - virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D); - virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D); - virtual void CompleteTentativeDefinition(VarDecl *D); - virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired); - virtual ASTMutationListener *GetASTMutationListener(); - virtual ASTDeserializationListener *GetASTDeserializationListener(); - virtual void PrintStats(); + void Initialize(ASTContext &Context) override; + void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override; + bool HandleTopLevelDecl(DeclGroupRef D) override; + void HandleInlineMethodDefinition(CXXMethodDecl *D) override; + void HandleInterestingDecl(DeclGroupRef D) override; + void HandleTranslationUnit(ASTContext &Ctx) override; + void HandleTagDeclDefinition(TagDecl *D) override; + void HandleTagDeclRequiredDefinition(const TagDecl *D) override; + void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override; + void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override; + void HandleImplicitImportDecl(ImportDecl *D) override; + void HandleLinkerOptionPragma(llvm::StringRef Opts) override; + void HandleDetectMismatch(llvm::StringRef Name, + llvm::StringRef Value) override; + void HandleDependentLibrary(llvm::StringRef Lib) override; + void CompleteTentativeDefinition(VarDecl *D) override; + void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override; + ASTMutationListener *GetASTMutationListener() override; + ASTDeserializationListener *GetASTDeserializationListener() override; + void PrintStats() override; // SemaConsumer - virtual void InitializeSema(Sema &S); - virtual void ForgetSema(); + void InitializeSema(Sema &S) override; + void ForgetSema() override; private: std::vector<ASTConsumer*> Consumers; // Owns these. - OwningPtr<MultiplexASTMutationListener> MutationListener; - OwningPtr<MultiplexASTDeserializationListener> DeserializationListener; + std::unique_ptr<MultiplexASTMutationListener> MutationListener; + std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener; }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticPrinter.h b/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticPrinter.h index 117771d..4dda1fa 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticPrinter.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticPrinter.h @@ -46,6 +46,19 @@ enum RecordIDs { RECORD_LAST = RECORD_FIXIT }; +/// A stable version of DiagnosticIDs::Level. +/// +/// Do not change the order of values in this enum, and please increment the +/// serialized diagnostics version number when you add to it. +enum Level { + Ignored = 0, + Note, + Warning, + Error, + Fatal, + Remark +}; + /// \brief Returns a DiagnosticConsumer that serializes diagnostics to /// a bitcode file. /// diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h index c8d01b0..acebb90 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h @@ -63,52 +63,48 @@ public: /// formatting of their diagnostic messages. /// /// \param OS Where the message is printed - /// \param Level Used to colorizing the message + /// \param IsSupplemental true if this is a continuation note diagnostic /// \param Message The text actually printed /// \param CurrentColumn The starting column of the first line, accounting /// for any prefix. /// \param Columns The number of columns to use in line-wrapping, 0 disables /// all line-wrapping. /// \param ShowColors Enable colorizing of the message. - static void printDiagnosticMessage(raw_ostream &OS, - DiagnosticsEngine::Level Level, - StringRef Message, - unsigned CurrentColumn, unsigned Columns, - bool ShowColors); + static void printDiagnosticMessage(raw_ostream &OS, bool IsSupplemental, + StringRef Message, unsigned CurrentColumn, + unsigned Columns, bool ShowColors); protected: - virtual void emitDiagnosticMessage(SourceLocation Loc,PresumedLoc PLoc, - DiagnosticsEngine::Level Level, - StringRef Message, - ArrayRef<CharSourceRange> Ranges, - const SourceManager *SM, - DiagOrStoredDiag D); - - virtual void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, - DiagnosticsEngine::Level Level, - ArrayRef<CharSourceRange> Ranges, - const SourceManager &SM); - - virtual void emitCodeContext(SourceLocation Loc, - DiagnosticsEngine::Level Level, - SmallVectorImpl<CharSourceRange>& Ranges, - ArrayRef<FixItHint> Hints, - const SourceManager &SM) { + void emitDiagnosticMessage(SourceLocation Loc,PresumedLoc PLoc, + DiagnosticsEngine::Level Level, + StringRef Message, + ArrayRef<CharSourceRange> Ranges, + const SourceManager *SM, + DiagOrStoredDiag D) override; + + void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, + DiagnosticsEngine::Level Level, + ArrayRef<CharSourceRange> Ranges, + const SourceManager &SM) override; + + void emitCodeContext(SourceLocation Loc, + DiagnosticsEngine::Level Level, + SmallVectorImpl<CharSourceRange>& Ranges, + ArrayRef<FixItHint> Hints, + const SourceManager &SM) override { emitSnippetAndCaret(Loc, Level, Ranges, Hints, SM); } - - virtual void emitBasicNote(StringRef Message); - - virtual void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, - const SourceManager &SM); - virtual void emitImportLocation(SourceLocation Loc, PresumedLoc PLoc, - StringRef ModuleName, - const SourceManager &SM); + void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, + const SourceManager &SM) override; + + void emitImportLocation(SourceLocation Loc, PresumedLoc PLoc, + StringRef ModuleName, + const SourceManager &SM) override; - virtual void emitBuildingModuleLocation(SourceLocation Loc, PresumedLoc PLoc, - StringRef ModuleName, - const SourceManager &SM); + void emitBuildingModuleLocation(SourceLocation Loc, PresumedLoc PLoc, + StringRef ModuleName, + const SourceManager &SM) override; private: void emitSnippetAndCaret(SourceLocation Loc, DiagnosticsEngine::Level Level, diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h index 93ac299..fe5aa3e 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticBuffer.h @@ -28,7 +28,7 @@ public: typedef DiagList::iterator iterator; typedef DiagList::const_iterator const_iterator; private: - DiagList Errors, Warnings, Notes; + DiagList Errors, Warnings, Remarks, Notes; public: const_iterator err_begin() const { return Errors.begin(); } const_iterator err_end() const { return Errors.end(); } @@ -36,11 +36,14 @@ public: const_iterator warn_begin() const { return Warnings.begin(); } const_iterator warn_end() const { return Warnings.end(); } + const_iterator remark_begin() const { return Remarks.begin(); } + const_iterator remark_end() const { return Remarks.end(); } + const_iterator note_begin() const { return Notes.begin(); } const_iterator note_end() const { return Notes.end(); } - virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, - const Diagnostic &Info); + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info) override; /// FlushDiagnostics - Flush the buffered diagnostics to an given /// diagnostic engine. diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h index dc80470..9f6d5ff 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h @@ -18,7 +18,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" -#include "llvm/ADT/OwningPtr.h" +#include <memory> namespace clang { class DiagnosticOptions; @@ -30,7 +30,7 @@ class TextDiagnosticPrinter : public DiagnosticConsumer { IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; /// \brief Handle to the currently active text diagnostic emitter. - OwningPtr<TextDiagnostic> TextDiag; + std::unique_ptr<TextDiagnostic> TextDiag; /// A string to prefix to error messages. std::string Prefix; @@ -47,9 +47,10 @@ public: /// used. void setPrefix(std::string Value) { Prefix = Value; } - void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP); - void EndSourceFile(); - void HandleDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info); + void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override; + void EndSourceFile() override; + void HandleDiagnostic(DiagnosticsEngine::Level Level, + const Diagnostic &Info) override; }; } // 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 dff56c3..4c0a7b7 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h @@ -15,8 +15,10 @@ #define LLVM_CLANG_FRONTEND_UTILS_H #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/VirtualFileSystem.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSet.h" #include "llvm/Option/OptSpecifier.h" namespace llvm { @@ -30,12 +32,14 @@ class ArgList; namespace clang { class ASTConsumer; +class ASTReader; class CompilerInstance; class CompilerInvocation; class Decl; class DependencyOutputOptions; class DiagnosticsEngine; class DiagnosticOptions; +class ExternalSemaSource; class FileManager; class HeaderSearch; class HeaderSearchOptions; @@ -59,23 +63,81 @@ void ApplyHeaderSearchOptions(HeaderSearch &HS, /// 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(DiagnosticsEngine &Diags, - const DiagnosticOptions &Opts, - bool ReportDiags = true); - /// DoPrintPreprocessedInput - Implement -E mode. void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS, const PreprocessorOutputOptions &Opts); -/// 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); +/// An interface for collecting the dependencies of a compilation. Users should +/// use \c attachToPreprocessor and \c attachToASTReader to get all of the +/// dependencies. +// FIXME: Migrate DependencyFileGen, DependencyGraphGen, ModuleDepCollectory to +// use this interface. +class DependencyCollector { +public: + void attachToPreprocessor(Preprocessor &PP); + void attachToASTReader(ASTReader &R); + llvm::ArrayRef<std::string> getDependencies() const { return Dependencies; } + + /// Called when a new file is seen. Return true if \p Filename should be added + /// to the list of dependencies. + /// + /// The default implementation ignores <built-in> and system files. + virtual bool sawDependency(StringRef Filename, bool FromModule, + bool IsSystem, bool IsModuleFile, bool IsMissing); + /// Called when the end of the main file is reached. + virtual void finishedMainFile() { } + /// Return true if system files should be passed to sawDependency(). + virtual bool needSystemDependencies() { return false; } + virtual ~DependencyCollector(); + +public: // implementation detail + /// Add a dependency \p Filename if it has not been seen before and + /// sawDependency() returns true. + void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem, + bool IsModuleFile, bool IsMissing); +private: + llvm::StringSet<> Seen; + std::vector<std::string> Dependencies; +}; + +/// Builds a depdenency file when attached to a Preprocessor (for includes) and +/// ASTReader (for module imports), and writes it out at the end of processing +/// a source file. Users should attach to the ast reader whenever a module is +/// loaded. +class DependencyFileGenerator { + void *Impl; // Opaque implementation + DependencyFileGenerator(void *Impl); +public: + static DependencyFileGenerator *CreateAndAttachToPreprocessor( + Preprocessor &PP, const DependencyOutputOptions &Opts); + void AttachToASTReader(ASTReader &R); +}; + +/// Collects the dependencies for imported modules into a directory. Users +/// should attach to the AST reader whenever a module is loaded. +class ModuleDependencyCollector { + std::string DestDir; + bool HasErrors; + llvm::StringSet<> Seen; + vfs::YAMLVFSWriter VFSWriter; + +public: + StringRef getDest() { return DestDir; } + bool insertSeen(StringRef Filename) { return Seen.insert(Filename); } + void setHasErrors() { HasErrors = true; } + void addFileMapping(StringRef VPath, StringRef RPath) { + VFSWriter.addFileMapping(VPath, RPath); + } + + void attachToASTReader(ASTReader &R); + void writeFileMap(); + bool hasErrors() { return HasErrors; } + ModuleDependencyCollector(std::string DestDir) + : DestDir(DestDir), HasErrors(false) {} + ~ModuleDependencyCollector() { writeFileMap(); } +}; /// AttachDependencyGraphGen - Create a dependency graph generator, and attach /// it to the given preprocessor. @@ -101,6 +163,12 @@ void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false, /// a seekable stream. void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); +/// The ChainedIncludesSource class converts headers to chained PCHs in +/// memory, mainly for testing. +IntrusiveRefCntPtr<ExternalSemaSource> +createChainedIncludesSource(CompilerInstance &CI, + IntrusiveRefCntPtr<ExternalSemaSource> &Reader); + /// createInvocationFromCommandLine - Construct a compiler invocation object for /// a command line argument vector. /// @@ -115,7 +183,7 @@ createInvocationFromCommandLine(ArrayRef<const char *> Args, /// is non-null, emits an error if the argument is given, but non-integral. int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, - DiagnosticsEngine *Diags = 0); + DiagnosticsEngine *Diags = nullptr); inline int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, @@ -123,6 +191,22 @@ inline int getLastArgIntValue(const llvm::opt::ArgList &Args, return getLastArgIntValue(Args, Id, Default, &Diags); } +uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, + llvm::opt::OptSpecifier Id, uint64_t Default, + DiagnosticsEngine *Diags = nullptr); + +inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, + llvm::opt::OptSpecifier Id, + uint64_t Default, + DiagnosticsEngine &Diags) { + return getLastArgUInt64Value(Args, Id, Default, &Diags); +} + +// When Clang->getFrontendOpts().DisableFree is set we don't delete some of the +// global objects, but we don't want LeakDetectors to complain, so we bury them +// in a globally visible array. +void BuryPointer(const void *Ptr); + } // end namespace clang #endif diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h b/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h index 95d7752..9273fac 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -13,10 +13,10 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/STLExtras.h" #include <climits> +#include <memory> namespace clang { @@ -34,12 +34,12 @@ class FileEntry; /// comment on the line that has the diagnostic, use: /// /// \code -/// expected-{error,warning,note} +/// expected-{error,warning,remark,note} /// \endcode /// -/// 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. +/// to tag if it's an expected error, remark 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: /// @@ -71,7 +71,10 @@ class FileEntry; /// \endcode /// /// The path can be absolute or relative and the same search paths will be used -/// as for #include directives. +/// as for #include directives. The line number in an external file may be +/// substituted with '*' meaning that any line number will match (useful where +/// the included file is, for example, a system header where the actual line +/// number may change and is not critical). /// /// The simple syntax above allows each specification to match exactly one /// error. You can use the extended syntax to customize this. The extended @@ -108,10 +111,11 @@ class FileEntry; /// /// In this example, the diagnostic may appear only once, if at all. /// -/// Regex matching mode may be selected by appending '-re' to type, such as: +/// Regex matching mode may be selected by appending '-re' to type and +/// including regexes wrapped in double curly braces in the directive, such as: /// /// \code -/// expected-error-re +/// expected-error-re {{format specifies type 'wchar_t **' (aka '{{.+}}')}} /// \endcode /// /// Examples matching error: "variable has incomplete type 'struct s'" @@ -120,10 +124,10 @@ class FileEntry; /// // 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:]](.*)'}} +/// // expected-error-re {{variable has type 'struct {{.}}'}} +/// // expected-error-re {{variable has type 'struct {{.*}}'}} +/// // expected-error-re {{variable has type 'struct {{(.*)}}'}} +/// // expected-error-re {{variable has type 'struct{{[[:space:]](.*)}}'}} /// \endcode /// /// VerifyDiagnosticConsumer expects at least one expected-* directive to @@ -142,7 +146,7 @@ public: class Directive { public: static Directive *create(bool RegexKind, SourceLocation DirectiveLoc, - SourceLocation DiagnosticLoc, + SourceLocation DiagnosticLoc, bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max); public: /// Constant representing n or more matches. @@ -152,6 +156,7 @@ public: SourceLocation DiagnosticLoc; const std::string Text; unsigned Min, Max; + bool MatchAnyLine; virtual ~Directive() { } @@ -164,9 +169,9 @@ public: protected: Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, - StringRef Text, unsigned Min, unsigned Max) + bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max) : DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc), - Text(Text), Min(Min), Max(Max) { + Text(Text), Min(Min), Max(Max), MatchAnyLine(MatchAnyLine) { assert(!DirectiveLoc.isInvalid() && "DirectiveLoc is invalid!"); assert(!DiagnosticLoc.isInvalid() && "DiagnosticLoc is invalid!"); } @@ -183,13 +188,17 @@ public: struct ExpectedData { DirectiveList Errors; DirectiveList Warnings; + DirectiveList Remarks; DirectiveList Notes; - ~ExpectedData() { + void Reset() { llvm::DeleteContainerPointers(Errors); llvm::DeleteContainerPointers(Warnings); + llvm::DeleteContainerPointers(Remarks); llvm::DeleteContainerPointers(Notes); } + + ~ExpectedData() { Reset(); } }; enum DirectiveStatus { @@ -203,7 +212,7 @@ private: DiagnosticsEngine &Diags; DiagnosticConsumer *PrimaryClient; bool OwnsPrimaryClient; - OwningPtr<TextDiagnosticBuffer> Buffer; + std::unique_ptr<TextDiagnosticBuffer> Buffer; const Preprocessor *CurrentPreprocessor; const LangOptions *LangOpts; SourceManager *SrcManager; @@ -217,24 +226,19 @@ private: SrcManager = &SM; } -#ifndef NDEBUG + // These facilities are used for validation in debug builds. class UnparsedFileStatus { llvm::PointerIntPair<const FileEntry *, 1, bool> Data; - public: UnparsedFileStatus(const FileEntry *File, bool FoundDirectives) : Data(File, FoundDirectives) {} - const FileEntry *getFile() const { return Data.getPointer(); } bool foundDirectives() const { return Data.getInt(); } }; - typedef llvm::DenseMap<FileID, const FileEntry *> ParsedFilesMap; typedef llvm::DenseMap<FileID, UnparsedFileStatus> UnparsedFilesMap; - ParsedFilesMap ParsedFiles; UnparsedFilesMap UnparsedFiles; -#endif public: /// Create a new verifying diagnostic client, which will issue errors to @@ -243,10 +247,10 @@ public: VerifyDiagnosticConsumer(DiagnosticsEngine &Diags); ~VerifyDiagnosticConsumer(); - virtual void BeginSourceFile(const LangOptions &LangOpts, - const Preprocessor *PP); + void BeginSourceFile(const LangOptions &LangOpts, + const Preprocessor *PP) override; - virtual void EndSourceFile(); + void EndSourceFile() override; enum ParsedStatus { /// File has been processed via HandleComment. @@ -262,10 +266,10 @@ public: /// \brief Update lists of parsed and unparsed files. void UpdateParsedFileStatus(SourceManager &SM, FileID FID, ParsedStatus PS); - virtual bool HandleComment(Preprocessor &PP, SourceRange Comment); + bool HandleComment(Preprocessor &PP, SourceRange Comment) override; - virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, - const Diagnostic &Info); + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info) override; }; } // end namspace clang |