diff options
Diffstat (limited to 'include/clang/Frontend')
24 files changed, 397 insertions, 167 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h index cca243d..c45bd40 100644 --- a/include/clang/Frontend/ASTConsumers.h +++ b/include/clang/Frontend/ASTConsumers.h @@ -18,8 +18,6 @@ namespace llvm { class raw_ostream; - class Module; - class LLVMContext; namespace sys { class Path; } } namespace clang { @@ -48,6 +46,10 @@ ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS); // intended for debugging. ASTConsumer *CreateASTDumper(); +// AST XML-dumper: dumps out the AST to stderr in a very detailed XML +// format; this is intended for particularly intense debugging. +ASTConsumer *CreateASTDumperXML(llvm::raw_ostream &OS); + // Graphical AST viewer: for each function definition, creates a graph of // the AST and displays it with the graph viewer "dotty". Also outputs // function declarations to stderr. @@ -57,10 +59,6 @@ ASTConsumer *CreateASTViewer(); // to stderr; this is intended for debugging. ASTConsumer *CreateDeclContextPrinter(); -// Inheritance viewer: for C++ code, creates a graph of the inheritance -// tree for the given class and displays it with "dotty". -ASTConsumer *CreateInheritanceViewer(const std::string& clsname); - } // end clang namespace #endif diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index e3fd4b3..e935633 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -21,13 +21,13 @@ #include "clang/Lex/PreprocessingRecord.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" #include "clang-c/Index.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" -#include "llvm/System/Path.h" -#include "llvm/Support/Timer.h" +#include "llvm/Support/Path.h" #include <map> #include <string> #include <vector> @@ -54,6 +54,14 @@ class TargetInfo; using namespace idx; +/// \brief Allocator for a cached set of global code completions. +class GlobalCodeCompletionAllocator + : public CodeCompletionAllocator, + public llvm::RefCountedBase<GlobalCodeCompletionAllocator> +{ + +}; + /// \brief Utility class for loading a ASTContext from an AST file. /// class ASTUnit { @@ -69,7 +77,9 @@ private: llvm::OwningPtr<TargetInfo> Target; llvm::OwningPtr<Preprocessor> PP; llvm::OwningPtr<ASTContext> Ctx; - + + FileSystemOptions FileSystemOpts; + /// \brief The AST consumer that received information about the translation /// unit as it was parsed or loaded. llvm::OwningPtr<ASTConsumer> Consumer; @@ -82,6 +92,13 @@ private: /// LoadFromCommandLine available. llvm::OwningPtr<CompilerInvocation> Invocation; + /// \brief The set of target features. + /// + /// FIXME: each time we reparse, we need to restore the set of target + /// features from this vector, because TargetInfo::CreateTargetInfo() + /// mangles the target options in place. Yuck! + std::vector<std::string> TargetFeatures; + // OnlyLocalDecls - when true, walking this AST should only visit declarations // that come from the AST itself, not from included precompiled headers. // FIXME: This is temporary; eventually, CIndex will always do this. @@ -89,13 +106,16 @@ private: /// \brief Whether to capture any diagnostics produced. bool CaptureDiagnostics; - + /// \brief Track whether the main file was loaded from an AST or not. bool MainFileIsAST; /// \brief Whether this AST represents a complete translation unit. bool CompleteTranslationUnit; + /// \brief Whether we should time each operation. + bool WantTiming; + /// Track the top-level decls which appeared in an ASTUnit which was loaded /// from a source file. // @@ -105,6 +125,14 @@ private: // 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; @@ -115,6 +143,13 @@ private: /// translation unit. llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics; + /// \brief The number of stored diagnostics that come from the driver + /// itself. + /// + /// Diagnostics that come from the driver are retained from one parse to + /// the next. + unsigned NumStoredDiagnosticsFromDriver; + /// \brief Temporary files that should be removed when the ASTUnit is /// destroyed. llvm::SmallVector<llvm::sys::Path, 4> TemporaryFiles; @@ -199,22 +234,21 @@ private: /// a precompiled preamble. unsigned NumStoredDiagnosticsInPreamble; - /// \brief The group of timers associated with this translation unit. - llvm::OwningPtr<llvm::TimerGroup> TimerGroup; - /// \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; - /// - /// \defgroup CodeCompleteCaching Code-completion caching - /// - /// \{ - /// - + /// \brief A list of the offsets into the precompiled preamble which + /// correspond to preprocessed entities. + std::vector<uint64_t> PreprocessedEntitiesInPreamble; + /// \brief Whether we should be caching code-completion results. bool ShouldCacheCodeCompletionResults; + static void ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags, + const char **ArgBegin, const char **ArgEnd, + ASTUnit &AST, bool CaptureDiagnostics); + public: /// \brief A cached code-completion result, which may be introduced in one of /// many different contexts. @@ -261,7 +295,17 @@ public: return CachedCompletionTypes; } + /// \brief Retrieve the allocator used to cache global code completions. + llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + getCachedCompletionAllocator() { + return CachedCompletionAllocator; + } + private: + /// \brief Allocator used to store cached code completions. + llvm::IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + CachedCompletionAllocator; + /// \brief The set of cached code-completion results. std::vector<CachedCodeCompletionResult> CachedCompletionResults; @@ -269,20 +313,24 @@ private: /// type, which is used for type equality comparisons. llvm::StringMap<unsigned> CachedCompletionTypes; - /// \brief The number of top-level declarations present the last time we - /// cached code-completion results. + /// \brief A string hash of the top-level declaration and macro definition + /// names processed the last time that we reparsed the file. /// - /// The value is used to help detect when we should repopulate the global - /// completion cache. - unsigned NumTopLevelDeclsAtLastCompletionCache; + /// This hash value is used to determine when we need to refresh the + /// global code-completion cache. + unsigned CompletionCacheTopLevelHashValue; - /// \brief The number of reparses left until we'll consider updating the - /// code-completion cache. + /// \brief A string hash of the top-level declaration and macro definition + /// names processed the last time that we reparsed the precompiled preamble. /// - /// This is meant to avoid thrashing during reparsing, by not allowing the - /// code-completion cache to be updated on every reparse. - unsigned CacheCodeCompletionCoolDown; + /// This hash value is used to determine when we need to refresh the + /// global code-completion cache after a rebuild of the precompiled preamble. + unsigned PreambleTopLevelHashValue; + /// \brief The current hash value for the top-level declaration and macro + /// definition names + unsigned CurrentTopLevelHashValue; + /// \brief Bit used by CIndex to mark when a translation unit may be in an /// inconsistent state, and is not safe to free. unsigned UnsafeToFree : 1; @@ -294,14 +342,6 @@ private: /// \brief Clear out and deallocate void ClearCachedCompletionResults(); - /// - /// \} - /// - - /// \brief The timers we've created from the various parses, reparses, etc. - /// involved in this translation unit. - std::vector<llvm::Timer *> Timers; - ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT @@ -319,7 +359,8 @@ private: bool AllowRebuild = true, unsigned MaxLines = 0); void RealizeTopLevelDeclsFromPreamble(); - + void RealizePreprocessedEntitiesFromPreamble(); + public: class ConcurrencyCheck { volatile ASTUnit &Self; @@ -367,6 +408,8 @@ public: const FileManager &getFileManager() const { return *FileMgr; } FileManager &getFileManager() { return *FileMgr; } + const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } + const std::string &getOriginalSourceFileName(); const std::string &getASTFileName(); @@ -386,6 +429,9 @@ public: void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } ASTLocation getLastASTLocation() const { return LastLoc; } + + llvm::StringRef getMainFileName() const; + typedef std::vector<Decl *>::iterator top_level_iterator; top_level_iterator top_level_begin() { @@ -423,6 +469,22 @@ public: TopLevelDeclsInPreamble.push_back(D); } + /// \brief Retrieve a reference to the current top-level name hash value. + /// + /// Note: This is used internally by the top-level tracking action + unsigned &getCurrentTopLevelHashValue() { return CurrentTopLevelHashValue; } + + typedef std::vector<PreprocessedEntity *>::iterator pp_entity_iterator; + + pp_entity_iterator pp_entity_begin(); + pp_entity_iterator pp_entity_end(); + + /// \brief Add a new preprocessed entity that's stored at the given offset + /// in the precompiled preamble. + void addPreprocessedEntityFromPreamble(uint64_t Offset) { + PreprocessedEntitiesInPreamble.push_back(Offset); + } + /// \brief Retrieve the mapping from File IDs to the preprocessed entities /// within that file. PreprocessedEntitiesByFileMap &getPreprocessedEntitiesByFile() { @@ -457,7 +519,10 @@ public: unsigned cached_completion_size() const { return CachedCompletionResults.size(); } - + + llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename, + std::string *ErrorStr = 0); + /// \brief Whether this AST represents a complete translation unit. /// /// If false, this AST is only a partial translation unit, e.g., one @@ -478,11 +543,25 @@ public: /// \returns - The initialized ASTUnit or null if the AST failed to load. static ASTUnit *LoadFromASTFile(const std::string &Filename, llvm::IntrusiveRefCntPtr<Diagnostic> Diags, + const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls = false, RemappedFile *RemappedFiles = 0, unsigned NumRemappedFiles = 0, bool CaptureDiagnostics = false); +private: + /// \brief Helper function for \c LoadFromCompilerInvocation() and + /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation. + /// + /// \param PrecompilePreamble Whether to precompile the preamble of this + /// translation unit, to improve the performance of reparsing. + /// + /// \returns \c true if a catastrophic failure occurred (which means that the + /// \c ASTUnit itself is invalid), or \c false otherwise. + bool LoadFromCompilerInvocation(bool PrecompilePreamble); + +public: + /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a /// CompilerInvocation object. /// @@ -521,12 +600,14 @@ public: llvm::IntrusiveRefCntPtr<Diagnostic> Diags, llvm::StringRef ResourceFilesPath, bool OnlyLocalDecls = false, + bool CaptureDiagnostics = false, RemappedFile *RemappedFiles = 0, unsigned NumRemappedFiles = 0, - bool CaptureDiagnostics = false, bool PrecompilePreamble = false, bool CompleteTranslationUnit = true, - bool CacheCodeCompletionResults = false); + bool CacheCodeCompletionResults = false, + bool CXXPrecompilePreamble = false, + bool CXXChainedPCH = false); /// \brief Reparse the source files using the same command-line options that /// were originally used to produce this translation unit. diff --git a/include/clang/Frontend/Analyses.def b/include/clang/Frontend/Analyses.def index aaa3920..75b52a8 100644 --- a/include/clang/Frontend/Analyses.def +++ b/include/clang/Frontend/Analyses.def @@ -15,45 +15,12 @@ #define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE) #endif -ANALYSIS(CFGDump, "cfg-dump", - "Display Control-Flow Graphs", Code) - -ANALYSIS(CFGView, "cfg-view", - "View Control-Flow Graphs using GraphViz", Code) - -ANALYSIS(DisplayLiveVariables, "dump-live-variables", - "Print results of live variable analysis", Code) - -ANALYSIS(SecuritySyntacticChecks, "analyzer-check-security-syntactic", - "Perform quick security checks that require no data flow", Code) - -ANALYSIS(LLVMConventionChecker, "analyzer-check-llvm-conventions", - "Check code for LLVM codebase conventions (domain-specific)", - TranslationUnit) - -ANALYSIS(WarnDeadStores, "analyzer-check-dead-stores", - "Warn about stores to dead variables", Code) - ANALYSIS(WarnUninitVals, "warn-uninit-values", "Warn about uses of uninitialized variables", Code) - -ANALYSIS(WarnObjCMethSigs, "analyzer-check-objc-methodsigs", - "Warn about Objective-C method signatures with type incompatibilities", - ObjCImplementation) - -ANALYSIS(WarnObjCDealloc, "analyzer-check-objc-missing-dealloc", -"Warn about Objective-C classes that lack a correct implementation of -dealloc", - ObjCImplementation) -ANALYSIS(WarnObjCUnusedIvars, "analyzer-check-objc-unused-ivars", - "Warn about private ivars that are never used", ObjCImplementation) - ANALYSIS(ObjCMemChecker, "analyzer-check-objc-mem", "Run the [Core] Foundation reference count checker", Code) -ANALYSIS(WarnSizeofPointer, "warn-sizeof-pointer", - "Warn about unintended use of sizeof() on pointer expressions", Code) - #ifndef ANALYSIS_STORE #define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) #endif @@ -73,9 +40,10 @@ 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(HTML, "html", "Output analysis results using HTML", createHTMLDiagnosticClient, false) +ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", createPlistDiagnosticClient, true) +ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", "Output analysis results using HTML wrapped with Plists", createPlistHTMLDiagnosticClient, true) +ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results", createTextPathDiagnosticClient, true) #undef ANALYSIS #undef ANALYSIS_STORE diff --git a/include/clang/Frontend/AnalyzerOptions.h b/include/clang/Frontend/AnalyzerOptions.h index 9ed15ba..5806928 100644 --- a/include/clang/Frontend/AnalyzerOptions.h +++ b/include/clang/Frontend/AnalyzerOptions.h @@ -56,6 +56,8 @@ NUM_ANALYSIS_DIAG_CLIENTS class AnalyzerOptions { public: std::vector<Analyses> AnalysisList; + /// \brief Pair of checker name and enable/disable. + std::vector<std::pair<std::string, bool> > CheckersControlList; AnalysisStores AnalysisStoreOpt; AnalysisConstraints AnalysisConstraintsOpt; AnalysisDiagClients AnalysisDiagOpt; @@ -65,17 +67,20 @@ public: unsigned AnalyzeAll : 1; unsigned AnalyzerDisplayProgress : 1; unsigned AnalyzeNestedBlocks : 1; + unsigned AnalyzerStats : 1; unsigned EagerlyAssume : 1; - unsigned IdempotentOps : 1; + unsigned BufferOverflows : 1; unsigned PurgeDead : 1; unsigned TrimGraph : 1; unsigned VisualizeEGDot : 1; unsigned VisualizeEGUbi : 1; unsigned EnableExperimentalChecks : 1; unsigned EnableExperimentalInternalChecks : 1; - unsigned EnableIdempotentOperationChecker : 1; unsigned InlineCall : 1; unsigned UnoptimizedCFG : 1; + unsigned CFGAddImplicitDtors : 1; + unsigned CFGAddInitializers : 1; + unsigned EagerlyTrimEGraph : 1; public: AnalyzerOptions() { @@ -85,14 +90,20 @@ public: AnalyzeAll = 0; AnalyzerDisplayProgress = 0; AnalyzeNestedBlocks = 0; + AnalyzerStats = 0; EagerlyAssume = 0; + BufferOverflows = 0; PurgeDead = 1; TrimGraph = 0; VisualizeEGDot = 0; VisualizeEGUbi = 0; EnableExperimentalChecks = 0; EnableExperimentalInternalChecks = 0; + InlineCall = 0; UnoptimizedCFG = 0; + CFGAddImplicitDtors = 0; + CFGAddInitializers = 0; + EagerlyTrimEGraph = 0; } }; diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h index b3f5709..ee85b655 100644 --- a/include/clang/Frontend/CodeGenOptions.h +++ b/include/clang/Frontend/CodeGenOptions.h @@ -40,24 +40,32 @@ public: /// aliases to base ctors when possible. unsigned DataSections : 1; /// Set when -fdata-sections is enabled unsigned DebugInfo : 1; /// Should generate debug info (-g). + unsigned LimitDebugInfo : 1; /// Limit generated debug info to reduce size. unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled. unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in /// getting .bc files that correspond to the /// internal state before optimizations are /// done. unsigned DisableRedZone : 1; /// Set when -mno-red-zone is enabled. - unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what Decl* - /// various IR entities came from. Only useful - /// when running CodeGen as a subroutine. + unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what + /// Decl* various IR entities came from. Only + /// useful when running CodeGen as a + /// subroutine. unsigned FunctionSections : 1; /// Set when -ffunction-sections is enabled unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for /// template classes with hidden visibility unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with - /// hidden visibility - unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is enabled + /// hidden visibility. + unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is + /// enabled. + unsigned InstrumentForProfiling : 1; /// Set when -pg is enabled + unsigned LessPreciseFPMAD : 1; /// Enable less precise MAD instructions to be + /// generated. unsigned MergeAllConstants : 1; /// Merge identical constants. unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled. unsigned NoImplicitFloat : 1; /// Set when -mno-implicit-float is enabled. + unsigned NoInfsFPMath : 1; /// Assume FP arguments, results not +-Inf. + unsigned NoNaNsFPMath : 1; /// Assume FP arguments, results not NaN. unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use. unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is @@ -65,12 +73,14 @@ public: unsigned OptimizationLevel : 3; /// The -O[0-4] option specified. unsigned OptimizeSize : 1; /// If -Os is specified. unsigned RelaxAll : 1; /// Relax all machine code instructions. + unsigned RelaxedAliasing : 1; /// Set when -fno-strict-aliasing is enabled. unsigned SimplifyLibCalls : 1; /// Set when -fbuiltin is enabled. unsigned SoftFloat : 1; /// -soft-float. unsigned TimePasses : 1; /// Set when -ftime-report is enabled. unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization /// selection. unsigned UnrollLoops : 1; /// Control whether loops are unrolled. + unsigned UnsafeFPMath : 1; /// Allow unsafe floating point optzns. unsigned UnwindTables : 1; /// Emit unwind tables. unsigned VerifyModule : 1; /// Control whether the module should be run /// through the LLVM Verifier. @@ -102,6 +112,10 @@ public: /// The name of the relocation model to use. std::string RelocationModel; + /// The user specified number of registers to be used for integral arguments, + /// or 0 if unspecified. + unsigned NumRegisterParameters; + public: CodeGenOptions() { AsmVerbose = 0; @@ -109,6 +123,7 @@ public: CXXCtorDtorAliases = 0; DataSections = 0; DebugInfo = 0; + LimitDebugInfo = 0; DisableFPElim = 0; DisableLLVMOpts = 0; DisableRedZone = 0; @@ -117,20 +132,27 @@ public: HiddenWeakTemplateVTables = 0; HiddenWeakVTables = 0; InstrumentFunctions = 0; + InstrumentForProfiling = 0; + LessPreciseFPMAD = 0; MergeAllConstants = 1; NoCommon = 0; NoImplicitFloat = 0; + NoInfsFPMath = 0; + NoNaNsFPMath = 0; NoZeroInitializedInBSS = 0; + NumRegisterParameters = 0; ObjCDispatchMethod = Legacy; OmitLeafFramePointer = 0; OptimizationLevel = 0; OptimizeSize = 0; RelaxAll = 0; + RelaxedAliasing = 0; SimplifyLibCalls = 1; SoftFloat = 0; TimePasses = 0; UnitAtATime = 1; UnrollLoops = 0; + UnsafeFPMath = 0; UnwindTables = 0; VerifyModule = 1; diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h index bea468b..8911cfa 100644 --- a/include/clang/Frontend/CommandLineSourceLoc.h +++ b/include/clang/Frontend/CommandLineSourceLoc.h @@ -37,9 +37,15 @@ public: // If both tail splits were valid integers, return success. if (!ColSplit.second.getAsInteger(10, PSL.Column) && - !LineSplit.second.getAsInteger(10, PSL.Line)) + !LineSplit.second.getAsInteger(10, PSL.Line)) { PSL.FileName = LineSplit.first; + // On the command-line, stdin may be specified via "-". Inside the + // compiler, stdin is called "<stdin>". + if (PSL.FileName == "-") + PSL.FileName = "<stdin>"; + } + return PSL; } }; diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 1b3c336..7ea79e5 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -19,7 +19,6 @@ #include <string> namespace llvm { -class LLVMContext; class raw_ostream; class raw_fd_ostream; class Timer; @@ -59,9 +58,6 @@ class TargetInfo; /// come in two forms; a short form that reuses the CompilerInstance objects, /// and a long form that takes explicit instances of any required objects. class CompilerInstance { - /// The LLVM context used for this instance. - llvm::OwningPtr<llvm::LLVMContext> LLVMContext; - /// The options used in this compiler instance. llvm::OwningPtr<CompilerInvocation> Invocation; @@ -95,8 +91,23 @@ class CompilerInstance { /// The frontend timer llvm::OwningPtr<llvm::Timer> FrontendTimer; + /// \brief Holds information about the output file. + /// + /// If TempFilename is not empty we must rename it to Filename at the end. + /// TempFilename may be empty and Filename non empty if creating the temporary + /// failed. + struct OutputFile { + std::string Filename; + std::string TempFilename; + llvm::raw_ostream *OS; + + OutputFile(const std::string &filename, const std::string &tempFilename, + llvm::raw_ostream *os) + : Filename(filename), TempFilename(tempFilename), OS(os) { } + }; + /// The list of active output files. - std::list< std::pair<std::string, llvm::raw_ostream*> > OutputFiles; + std::list<OutputFile> OutputFiles; void operator=(const CompilerInstance &); // DO NOT IMPLEMENT CompilerInstance(const CompilerInstance&); // DO NOT IMPLEMENT @@ -140,23 +151,6 @@ public: bool ExecuteAction(FrontendAction &Act); /// } - /// @name LLVM Context - /// { - - bool hasLLVMContext() const { return LLVMContext != 0; } - - llvm::LLVMContext &getLLVMContext() const { - assert(LLVMContext && "Compiler instance has no LLVM context!"); - return *LLVMContext; - } - - llvm::LLVMContext *takeLLVMContext() { return LLVMContext.take(); } - - /// setLLVMContext - Replace the current LLVM context and take ownership of - /// \arg Value. - void setLLVMContext(llvm::LLVMContext *Value); - - /// } /// @name Compiler Invocation and Options /// { @@ -205,6 +199,10 @@ public: return Invocation->getDiagnosticOpts(); } + const FileSystemOptions &getFileSystemOpts() const { + return Invocation->getFileSystemOpts(); + } + FrontendOptions &getFrontendOpts() { return Invocation->getFrontendOpts(); } @@ -435,16 +433,10 @@ public: /// @name Output Files /// { - /// getOutputFileList - Get the list of (path, output stream) pairs of output - /// files; the path may be empty but the stream will always be non-null. - const std::list< std::pair<std::string, - llvm::raw_ostream*> > &getOutputFileList() const; - /// addOutputFile - Add an output file onto the list of tracked output files. /// - /// \param Path - The path to the output file, or empty. - /// \param OS - The output stream, which should be non-null. - void addOutputFile(llvm::StringRef Path, llvm::raw_ostream *OS); + /// \param OutFile - The output file info. + void addOutputFile(const OutputFile &OutFile); /// clearOutputFiles - Clear the output file list, destroying the contained /// output streams. @@ -459,8 +451,14 @@ public: /// Create the diagnostics engine using the invocation's diagnostic options /// and replace any existing one with it. /// - /// Note that this routine also replaces the diagnostic client. - void createDiagnostics(int Argc, char **Argv); + /// Note that this routine also replaces the diagnostic client, + /// allocating one if one is not provided. + /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the Diagnostic inside this AST + /// unit. + void createDiagnostics(int Argc, const char* const *Argv, + DiagnosticClient *Client = 0); /// Create a Diagnostic object with a the TextDiagnosticPrinter. /// @@ -468,23 +466,30 @@ public: /// when the diagnostic options indicate that the compiler should output /// logging information. /// - /// Note that this creates an unowned DiagnosticClient, if using directly the - /// caller is responsible for releasing the returned Diagnostic's client - /// eventually. + /// If no diagnostic client is provided, this creates a + /// DiagnosticClient that is owned by the returned diagnostic + /// object, if using directly the caller is responsible for + /// releasing the returned Diagnostic's client eventually. /// /// \param Opts - The diagnostic options; note that the created text /// diagnostic object contains a reference to these options and its lifetime /// must extend past that of the diagnostic engine. /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the returned Diagnostic + /// object. + /// /// \return The new object on success, or null on failure. static llvm::IntrusiveRefCntPtr<Diagnostic> - createDiagnostics(const DiagnosticOptions &Opts, int Argc, char **Argv); + createDiagnostics(const DiagnosticOptions &Opts, int Argc, + const char* const *Argv, + DiagnosticClient *Client = 0); /// Create the file manager and replace any existing one with it. void createFileManager(); /// Create the source manager and replace any existing one with it. - void createSourceManager(); + void createSourceManager(FileManager &FileMgr); /// Create the preprocessor, using the invocation, file, and source managers, /// and replace any existing one with it. @@ -511,6 +516,7 @@ public: /// context. void createPCHExternalASTSource(llvm::StringRef Path, bool DisablePCHValidation, + bool DisableStatCache, void *DeserializationListener); /// Create an external AST source to read a PCH file. @@ -519,8 +525,9 @@ public: static ExternalASTSource * createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, + bool DisableStatCache, Preprocessor &PP, ASTContext &Context, - void *DeserializationListener); + void *DeserializationListener, bool Preamble); /// Create a code completion consumer using the invocation; note that this /// will cause the source manager to truncate the input source file at the @@ -533,7 +540,7 @@ public: static CodeCompleteConsumer * createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename, unsigned Line, unsigned Column, - bool UseDebugPrinter, bool ShowMacros, + bool ShowMacros, bool ShowCodePatterns, bool ShowGlobals, llvm::raw_ostream &OS); @@ -557,7 +564,8 @@ public: /// /// \return - Null on error. llvm::raw_fd_ostream * - createOutputFile(llvm::StringRef OutputPath, bool Binary = true, + createOutputFile(llvm::StringRef OutputPath, + bool Binary = true, bool RemoveFileOnSignal = true, llvm::StringRef BaseInput = "", llvm::StringRef Extension = ""); @@ -565,7 +573,8 @@ public: /// /// If \arg OutputPath is empty, then createOutputFile will derive an output /// path location as \arg BaseInput, with any suffix removed, and \arg - /// Extension appended. + /// Extension appended. If OutputPath is not stdout createOutputFile will + /// create a new temporary file that must be renamed to OutputPath in the end. /// /// \param OutputPath - If given, the path to the output file. /// \param Error [out] - On failure, the error message. @@ -573,13 +582,20 @@ public: /// for deriving the output path. /// \param Extension - The extension to use for derived output names. /// \param Binary - The mode to open the file in. + /// \param RemoveFileOnSignal - Whether the file should be registered with + /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for + /// multithreaded use, as the underlying signal mechanism is not reentrant /// \param ResultPathName [out] - If given, the result path name will be /// stored here on success. + /// \param TempPathName [out] - If given, the temporary file path name + /// will be stored here on success. static llvm::raw_fd_ostream * createOutputFile(llvm::StringRef OutputPath, std::string &Error, - bool Binary = true, llvm::StringRef BaseInput = "", + bool Binary = true, bool RemoveFileOnSignal = true, + llvm::StringRef BaseInput = "", llvm::StringRef Extension = "", - std::string *ResultPathName = 0); + std::string *ResultPathName = 0, + std::string *TempPathName = 0); /// } /// @name Initialization Utility Methods diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h index d558ad3..e0329db 100644 --- a/include/clang/Frontend/CompilerInvocation.h +++ b/include/clang/Frontend/CompilerInvocation.h @@ -12,12 +12,14 @@ #include "clang/Basic/LangOptions.h" #include "clang/Basic/TargetOptions.h" +#include "clang/Basic/FileSystemOptions.h" #include "clang/Frontend/AnalyzerOptions.h" #include "clang/Frontend/CodeGenOptions.h" #include "clang/Frontend/DependencyOutputOptions.h" #include "clang/Frontend/DiagnosticOptions.h" #include "clang/Frontend/FrontendOptions.h" #include "clang/Frontend/HeaderSearchOptions.h" +#include "clang/Frontend/LangStandard.h" #include "clang/Frontend/PreprocessorOptions.h" #include "clang/Frontend/PreprocessorOutputOptions.h" #include "llvm/ADT/StringRef.h" @@ -52,6 +54,9 @@ class CompilerInvocation { /// Options controlling the diagnostic engine. DiagnosticOptions DiagnosticOpts; + /// Options controlling file system operations. + FileSystemOptions FileSystemOpts; + /// Options controlling the frontend itself. FrontendOptions FrontendOpts; @@ -83,8 +88,10 @@ public: /// \param ArgBegin - The first element in the argument vector. /// \param ArgEnd - The last element in the argument vector. /// \param Diags - The diagnostic engine to use for errors. - static void CreateFromArgs(CompilerInvocation &Res, const char **ArgBegin, - const char **ArgEnd, Diagnostic &Diags); + static void CreateFromArgs(CompilerInvocation &Res, + const char* const *ArgBegin, + const char* const *ArgEnd, + Diagnostic &Diags); /// GetBuiltinIncludePath - Get the directory where the compiler headers /// reside, relative to the compiler binary (found by the passed in @@ -100,6 +107,25 @@ public: /// passing to CreateFromArgs. void toArgs(std::vector<std::string> &Res); + /// setLangDefaults - Set language defaults for the given input language and + /// language standard in this CompilerInvocation. + /// + /// \param IK - The input language. + /// \param LangStd - The input language standard. + void setLangDefaults(InputKind IK, + LangStandard::Kind LangStd = LangStandard::lang_unspecified) { + setLangDefaults(LangOpts, IK, LangStd); + } + + /// setLangDefaults - Set language defaults for the given input language and + /// language standard in the given LangOptions object. + /// + /// \param LangOpts - The LangOptions object to set up. + /// \param IK - The input language. + /// \param LangStd - The input language standard. + static void setLangDefaults(LangOptions &Opts, InputKind IK, + LangStandard::Kind LangStd = LangStandard::lang_unspecified); + /// @} /// @name Option Subgroups /// @{ @@ -124,6 +150,11 @@ public: DiagnosticOptions &getDiagnosticOpts() { return DiagnosticOpts; } const DiagnosticOptions &getDiagnosticOpts() const { return DiagnosticOpts; } + FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } + const FileSystemOptions &getFileSystemOpts() const { + return FileSystemOpts; + } + HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; } const HeaderSearchOptions &getHeaderSearchOpts() const { return HeaderSearchOpts; diff --git a/include/clang/Frontend/DeclXML.def b/include/clang/Frontend/DeclXML.def index 1845118..1b158fd 100644 --- a/include/clang/Frontend/DeclXML.def +++ b/include/clang/Frontend/DeclXML.def @@ -103,6 +103,9 @@ NODE_XML(FunctionDecl, "Function") ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") //ATTRIBUTE_OPT_XML(isVariadic(), "variadic") // in the type reference ATTRIBUTE_XML(getNumParams(), "num_args") + ATTRIBUTE_OPT_XML(isMain(), "main") + ATTRIBUTE_OPT_XML(isExternC(), "externc") + ATTRIBUTE_OPT_XML(isGlobal(), "global") SUB_NODE_SEQUENCE_XML(ParmVarDecl) SUB_NODE_FN_BODY_XML END_NODE_XML @@ -117,6 +120,7 @@ NODE_XML(CXXMethodDecl, "CXXMethod") ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") ATTRIBUTE_OPT_XML(isStatic(), "static") ATTRIBUTE_OPT_XML(isVirtual(), "virtual") + ATTRIBUTE_OPT_XML(isPure(), "pure") ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access") ENUM_XML(AS_none, "") ENUM_XML(AS_public, "public") @@ -316,6 +320,7 @@ NODE_XML(LinkageSpecDecl, "LinkageSpec") ENUM_XML(LinkageSpecDecl::lang_c, "C") ENUM_XML(LinkageSpecDecl::lang_cxx, "CXX") END_ENUM_XML + SUB_NODE_XML(DeclContext) END_NODE_XML NODE_XML(TemplateDecl, "Template") diff --git a/include/clang/Frontend/DependencyOutputOptions.h b/include/clang/Frontend/DependencyOutputOptions.h index ab8e49d..35aa6c6 100644 --- a/include/clang/Frontend/DependencyOutputOptions.h +++ b/include/clang/Frontend/DependencyOutputOptions.h @@ -20,13 +20,20 @@ namespace clang { class DependencyOutputOptions { public: unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies. + unsigned ShowHeaderIncludes : 1; ///< Show header inclusions (-H). unsigned UsePhonyTargets : 1; ///< Include phony targets for each /// dependency, which can avoid some 'make' /// problems. - /// The file to write depencency output to. + /// The file to write dependency output to. std::string OutputFile; + /// The file to write header include output to. This is orthogonal to + /// ShowHeaderIncludes (-H) and will include headers mentioned in the + /// predefines buffer. If the output file is "-", output will be sent to + /// stderr. + std::string HeaderIncludeOutputFile; + /// A list of names to use as the targets in the dependency file; this list /// must contain at least one entry. std::vector<std::string> Targets; @@ -34,6 +41,7 @@ public: public: DependencyOutputOptions() { IncludeSystemHeaders = 0; + ShowHeaderIncludes = 0; UsePhonyTargets = 0; } }; diff --git a/include/clang/Frontend/DiagnosticOptions.h b/include/clang/Frontend/DiagnosticOptions.h index c80bc03..f7f498b 100644 --- a/include/clang/Frontend/DiagnosticOptions.h +++ b/include/clang/Frontend/DiagnosticOptions.h @@ -41,9 +41,6 @@ public: unsigned VerifyDiagnostics: 1; /// Check that diagnostics match the expected /// diagnostics, indicated by markers in the /// input source file. - unsigned BinaryOutput : 1; /// Emit diagnostics via the diagnostic - /// binary serialization mechanism, to be - /// deserialized by, e.g., the CIndex library. unsigned ErrorLimit; /// Limit # errors emitted. unsigned MacroBacktraceLimit; /// Limit depth of macro instantiation @@ -86,7 +83,6 @@ public: ShowSourceRanges = 0; ShowParseableFixits = 0; VerifyDiagnostics = 0; - BinaryOutput = 0; ErrorLimit = 0; TemplateBacktraceLimit = DefaultTemplateBacktraceLimit; MacroBacktraceLimit = DefaultMacroBacktraceLimit; diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h index 773543a..ee0863a 100644 --- a/include/clang/Frontend/FrontendAction.h +++ b/include/clang/Frontend/FrontendAction.h @@ -37,6 +37,7 @@ enum InputKind { IK_PreprocessedObjC, IK_PreprocessedObjCXX, IK_OpenCL, + IK_CUDA, IK_AST, IK_LLVM_IR }; @@ -51,6 +52,10 @@ class FrontendAction { CompilerInstance *Instance; friend class ASTMergeAction; +private: + ASTConsumer* CreateWrappedASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); + protected: /// @name Implementation Action Interface /// @{ @@ -130,7 +135,7 @@ public: } ASTUnit &getCurrentASTUnit() const { - assert(!CurrentASTUnit && "No current AST unit!"); + assert(CurrentASTUnit && "No current AST unit!"); return *CurrentASTUnit; } diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h index 7b8063c..4df2e71 100644 --- a/include/clang/Frontend/FrontendActions.h +++ b/include/clang/Frontend/FrontendActions.h @@ -54,6 +54,12 @@ protected: llvm::StringRef InFile); }; +class ASTDumpXMLAction : public ASTFrontendAction { +protected: + virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile); +}; + class ASTViewAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, @@ -83,16 +89,11 @@ public: static bool ComputeASTConsumerArguments(CompilerInstance &CI, llvm::StringRef InFile, std::string &Sysroot, + std::string &OutputFile, llvm::raw_ostream *&OS, bool &Chaining); }; -class InheritanceViewAction : public ASTFrontendAction { -protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile); -}; - class SyntaxOnlyAction : public ASTFrontendAction { protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, diff --git a/include/clang/Frontend/FrontendDiagnostic.h b/include/clang/Frontend/FrontendDiagnostic.h index 61ad22c..2efbc81 100644 --- a/include/clang/Frontend/FrontendDiagnostic.h +++ b/include/clang/Frontend/FrontendDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM, #define FRONTENDSTART #include "clang/Basic/DiagnosticFrontendKinds.inc" #undef DIAG diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index 4c16d08..19d39c3 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -21,6 +21,7 @@ namespace clang { namespace frontend { enum ActionKind { ASTDump, ///< Parse ASTs and dump them. + ASTDumpXML, ///< Parse ASTs and dump them in XML. ASTPrint, ///< Parse ASTs and print them. ASTPrintXML, ///< Parse ASTs and print them in XML. ASTView, ///< Parse ASTs and view them in Graphviz. @@ -38,7 +39,6 @@ namespace frontend { FixIt, ///< Parse and apply any fixits to the source. GeneratePCH, ///< Generate pre-compiled header. GeneratePTH, ///< Generate pre-tokenized header. - InheritanceView, ///< View C++ inheritance for a specified class. InitOnly, ///< Only execute frontend initialization. ParseSyntaxOnly, ///< Parse and perform semantic analysis. PluginAction, ///< Run a plugin action, \see ActionName. @@ -56,8 +56,6 @@ namespace frontend { /// FrontendOptions - Options for controlling the behavior of the frontend. class FrontendOptions { public: - unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code - /// completion results. unsigned DisableFree : 1; ///< Disable memory freeing on exit. unsigned RelocatablePCH : 1; ///< When generating PCH files, /// instruct the AST writer to create @@ -86,9 +84,6 @@ public: /// The output file, if any. std::string OutputFile; - /// If given, the name for a C++ class to view the inheritance of. - std::string ViewClassInheritance; - /// If given, the new suffix for fix-it rewritten files. std::string FixItSuffix; @@ -101,9 +96,15 @@ public: /// The name of the action to run when using a plugin action. std::string ActionName; - /// Arg to pass to the plugin + /// Args to pass to the plugin std::vector<std::string> PluginArgs; + /// The list of plugin actions to run in addition to the normal action. + std::vector<std::string> AddPluginActions; + + /// Args to pass to the additional plugins + std::vector<std::vector<std::string> > AddPluginArgs; + /// The list of plugins to load. std::vector<std::string> Plugins; @@ -119,7 +120,6 @@ public: public: FrontendOptions() { - DebugCodeCompletionPrinter = 1; DisableFree = 0; ProgramAction = frontend::ParseSyntaxOnly; ActionName = ""; diff --git a/include/clang/Frontend/HeaderSearchOptions.h b/include/clang/Frontend/HeaderSearchOptions.h index 588d32b..cbb4a57 100644 --- a/include/clang/Frontend/HeaderSearchOptions.h +++ b/include/clang/Frontend/HeaderSearchOptions.h @@ -54,6 +54,9 @@ public: /// User specified include entries. std::vector<Entry> UserEntries; + /// If non-empty, the list of C++ standard include paths to use. + std::vector<std::string> CXXSystemIncludes; + /// A (system-path) delimited list of include paths to be added from the /// environment following the user specified includes (but prior to builtin /// and standard includes). This is parsed in the same manner as the CPATH diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Frontend/LangStandards.def index 52aa463..d4046b3 100644 --- a/include/clang/Frontend/LangStandards.def +++ b/include/clang/Frontend/LangStandards.def @@ -80,4 +80,9 @@ LANGSTANDARD(opencl, "cl", "OpenCL 1.0", BCPLComment | C99 | Digraphs | HexFloat) +// CUDA +LANGSTANDARD(cuda, "cuda", + "NVIDIA CUDA(tm)", + BCPLComment | CPlusPlus | Digraphs) + #undef LANGSTANDARD diff --git a/include/clang/Frontend/MultiplexConsumer.h b/include/clang/Frontend/MultiplexConsumer.h new file mode 100644 index 0000000..560178b --- /dev/null +++ b/include/clang/Frontend/MultiplexConsumer.h @@ -0,0 +1,54 @@ +//===-- MultiplexConsumer.h - AST Consumer for PCH Generation ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the MultiplexConsumer class, which can be used to +// multiplex ASTConsumer and SemaConsumer messages to many consumers. +// +//===----------------------------------------------------------------------===// + +#include "clang/Sema/SemaConsumer.h" +#include "llvm/ADT/OwningPtr.h" +#include <vector> + +namespace clang { + +class MultiplexASTMutationListener; +class MultiplexASTDeserializationListener; + +// Has a list of ASTConsumers and calls each of them. Owns its children. +class MultiplexConsumer : public SemaConsumer { +public: + // Takes ownership of the pointers in C. + MultiplexConsumer(const std::vector<ASTConsumer*>& C); + ~MultiplexConsumer(); + + // ASTConsumer + virtual void Initialize(ASTContext &Context); + virtual void HandleTopLevelDecl(DeclGroupRef D); + virtual void HandleInterestingDecl(DeclGroupRef D); + virtual void HandleTranslationUnit(ASTContext &Ctx); + virtual void HandleTagDeclDefinition(TagDecl *D); + virtual void CompleteTentativeDefinition(VarDecl *D); + virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired); + virtual ASTMutationListener *GetASTMutationListener(); + virtual ASTDeserializationListener *GetASTDeserializationListener(); + virtual void PrintStats(); + + // SemaConsumer + virtual void InitializeSema(Sema &S); + virtual void ForgetSema(); + + static bool classof(const MultiplexConsumer *) { return true; } +private: + std::vector<ASTConsumer*> Consumers; // Owns these. + llvm::OwningPtr<MultiplexASTMutationListener> MutationListener; + llvm::OwningPtr<MultiplexASTDeserializationListener> DeserializationListener; +}; + +} // end namespace clang diff --git a/include/clang/Frontend/PreprocessorOptions.h b/include/clang/Frontend/PreprocessorOptions.h index 851c1f0..0d52e53 100644 --- a/include/clang/Frontend/PreprocessorOptions.h +++ b/include/clang/Frontend/PreprocessorOptions.h @@ -15,6 +15,7 @@ #include <string> #include <utility> #include <vector> +#include <set> namespace llvm { class MemoryBuffer; @@ -46,7 +47,18 @@ public: /// \brief When true, disables most of the normal validation performed on /// precompiled headers. bool DisablePCHValidation; - + + /// \brief When true, disables the use of the stat cache within a + /// precompiled header or AST file. + bool DisableStatCache; + + /// \brief Dump declarations that are deserialized from PCH, for testing. + bool DumpDeserializedPCHDecls; + + /// \brief This is a set of names for decls that we do not want to be + /// deserialized, and we emit an error if they are; for testing purposes. + std::set<std::string> DeserializedPCHDeclsToErrorOn; + /// \brief If non-zero, the implicit PCH include is actually a precompiled /// preamble that covers this number of bytes in the main source file. /// @@ -117,7 +129,8 @@ public: public: PreprocessorOptions() : UsePredefines(true), DetailedRecord(false), - DisablePCHValidation(false), + DisablePCHValidation(false), DisableStatCache(false), + DumpDeserializedPCHDecls(false), PrecompiledPreambleBytes(0, true), RetainRemappedFileBuffers(false) { } diff --git a/include/clang/Frontend/PreprocessorOutputOptions.h b/include/clang/Frontend/PreprocessorOutputOptions.h index 82517c5..1eda0d4 100644 --- a/include/clang/Frontend/PreprocessorOutputOptions.h +++ b/include/clang/Frontend/PreprocessorOutputOptions.h @@ -18,7 +18,6 @@ class PreprocessorOutputOptions { public: unsigned ShowCPP : 1; ///< Print normal preprocessed output. unsigned ShowComments : 1; ///< Show comments. - unsigned ShowHeaderIncludes : 1; ///< Show header inclusions (-H). unsigned ShowLineMarkers : 1; ///< Show #line markers. unsigned ShowMacroComments : 1; ///< Show comments, even in macros. unsigned ShowMacros : 1; ///< Print macro definitions. @@ -27,7 +26,6 @@ public: PreprocessorOutputOptions() { ShowCPP = 1; ShowComments = 0; - ShowHeaderIncludes = 0; ShowLineMarkers = 1; ShowMacroComments = 0; ShowMacros = 0; diff --git a/include/clang/Frontend/StmtXML.def b/include/clang/Frontend/StmtXML.def index c03a5a8..8a859e6 100644 --- a/include/clang/Frontend/StmtXML.def +++ b/include/clang/Frontend/StmtXML.def @@ -415,13 +415,6 @@ NODE_XML(StmtExpr, "StmtExpr") // StmtExpr contains a s SUB_NODE_XML(CompoundStmt) END_NODE_XML -NODE_XML(TypesCompatibleExpr, "TypesCompatibleExpr") // GNU builtin-in function __builtin_types_compatible_p - ATTRIBUTE_FILE_LOCATION_XML - TYPE_ATTRIBUTE_XML(getType()) - ATTRIBUTE_XML(getArgType1(), "type1_ref") // id of type1 - ATTRIBUTE_XML(getArgType2(), "type2_ref") // id of type2 -END_NODE_XML - NODE_XML(ChooseExpr, "ChooseExpr") // GNU builtin-in function __builtin_choose_expr(expr1, expr2, expr3) ATTRIBUTE_FILE_LOCATION_XML TYPE_ATTRIBUTE_XML(getType()) diff --git a/include/clang/Frontend/TypeXML.def b/include/clang/Frontend/TypeXML.def index 1536c92..b78e70f 100644 --- a/include/clang/Frontend/TypeXML.def +++ b/include/clang/Frontend/TypeXML.def @@ -98,7 +98,8 @@ NODE_XML(BuiltinType, "FundamentalType") ENUM_XML(BuiltinType::Float, "float"); ENUM_XML(BuiltinType::Double, "double"); ENUM_XML(BuiltinType::LongDouble, "long double"); - ENUM_XML(BuiltinType::WChar, "wchar_t"); + ENUM_XML(BuiltinType::WChar_U, "wchar_t"); + ENUM_XML(BuiltinType::WChar_S, "wchar_t"); ENUM_XML(BuiltinType::Char16, "char16_t"); ENUM_XML(BuiltinType::Char32, "char32_t"); ENUM_XML(BuiltinType::NullPtr, "nullptr_t"); // This is the type of C++0x 'nullptr'. @@ -130,6 +131,13 @@ NODE_XML(FunctionProtoType, "FunctionType") ID_ATTRIBUTE_XML ATTRIBUTE_XML(getResultType(), "result_type") ATTRIBUTE_OPT_XML(isVariadic(), "variadic") + ATTRIBUTE_ENUM_XML(getCallConv(), "call_conv") + ENUM_XML(CC_Default, "") + ENUM_XML(CC_C, "C") + ENUM_XML(CC_X86StdCall, "X86StdCall") + ENUM_XML(CC_X86FastCall, "X86FastCall") + ENUM_XML(CC_X86ThisCall, "X86ThisCall") + END_ENUM_XML END_NODE_XML NODE_XML(TypedefType, "Typedef") diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h index fe722db..485161b 100644 --- a/include/clang/Frontend/Utils.h +++ b/include/clang/Frontend/Utils.h @@ -73,6 +73,18 @@ bool CheckDiagnostics(Preprocessor &PP); void AttachDependencyFileGen(Preprocessor &PP, const DependencyOutputOptions &Opts); +/// AttachHeaderIncludeGen - Create a header include list generator, and attach +/// it to the given preprocessor. +/// +/// \param ShowAllHeaders - If true, show all header information instead of just +/// headers following the predefines buffer. This is useful for making sure +/// includes mentioned on the command line are also reported, but differs from +/// the default behavior used by -H. +/// \param OutputPath - If non-empty, a path to write the header include +/// information to, instead of writing to stderr. +void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false, + llvm::StringRef OutputPath = ""); + /// CacheTokens - Cache tokens for use with PCH. Note that this requires /// a seekable stream. void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); diff --git a/include/clang/Frontend/VerifyDiagnosticsClient.h b/include/clang/Frontend/VerifyDiagnosticsClient.h index 6f45e49..793cedd 100644 --- a/include/clang/Frontend/VerifyDiagnosticsClient.h +++ b/include/clang/Frontend/VerifyDiagnosticsClient.h @@ -68,7 +68,6 @@ public: llvm::OwningPtr<DiagnosticClient> PrimaryClient; llvm::OwningPtr<TextDiagnosticBuffer> Buffer; Preprocessor *CurrentPreprocessor; - unsigned NumErrors; private: void CheckDiagnostics(); @@ -88,9 +87,6 @@ public: virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, const DiagnosticInfo &Info); - - /// HadErrors - Check if there were any mismatches in expected diagnostics. - bool HadErrors(); }; } // end namspace clang |