diff options
author | dim <dim@FreeBSD.org> | 2017-04-02 17:24:58 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2017-04-02 17:24:58 +0000 |
commit | 60b571e49a90d38697b3aca23020d9da42fc7d7f (patch) | |
tree | 99351324c24d6cb146b6285b6caffa4d26fce188 /contrib/llvm/tools/clang/include/clang/Frontend | |
parent | bea1b22c7a9bce1dfdd73e6e5b65bc4752215180 (diff) | |
download | FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.zip FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.tar.gz |
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release:
MFC r309142 (by emaste):
Add WITH_LLD_AS_LD build knob
If set it installs LLD as /usr/bin/ld. LLD (as of version 3.9) is not
capable of linking the world and kernel, but can self-host and link many
substantial applications. GNU ld continues to be used for the world and
kernel build, regardless of how this knob is set.
It is on by default for arm64, and off for all other CPU architectures.
Sponsored by: The FreeBSD Foundation
MFC r310840:
Reapply 310775, now it also builds correctly if lldb is disabled:
Move llvm-objdump from CLANG_EXTRAS to installed by default
We currently install three tools from binutils 2.17.50: as, ld, and
objdump. Work is underway to migrate to a permissively-licensed
tool-chain, with one goal being the retirement of binutils 2.17.50.
LLVM's llvm-objdump is intended to be compatible with GNU objdump
although it is currently missing some options and may have formatting
differences. Enable it by default for testing and further investigation.
It may later be changed to install as /usr/bin/objdump, it becomes a
fully viable replacement.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D8879
MFC r312855 (by emaste):
Rename LLD_AS_LD to LLD_IS_LD, for consistency with CLANG_IS_CC
Reported by: Dan McGregor <dan.mcgregor usask.ca>
MFC r313559 | glebius | 2017-02-10 18:34:48 +0100 (Fri, 10 Feb 2017) | 5 lines
Don't check struct rtentry on FreeBSD, it is an internal kernel structure.
On other systems it may be API structure for SIOCADDRT/SIOCDELRT.
Reviewed by: emaste, dim
MFC r314152 (by jkim):
Remove an assembler flag, which is redundant since r309124. The upstream
took care of it by introducing a macro NO_EXEC_STACK_DIRECTIVE.
http://llvm.org/viewvc/llvm-project?rev=273500&view=rev
Reviewed by: dim
MFC r314564:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
4.0.0 (branches/release_40 296509). The release will follow soon.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Also note that as of 4.0.0, lld should be able to link the base system
on amd64 and aarch64. See the WITH_LLD_IS_LLD setting in src.conf(5).
Though please be aware that this is work in progress.
Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/4.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/lld/docs/ReleaseNotes.html>
Thanks to Ed Maste, Jan Beich, Antoine Brodin and Eric Fiselier for
their help.
Relnotes: yes
Exp-run: antoine
PR: 215969, 216008
MFC r314708:
For now, revert r287232 from upstream llvm trunk (by Daniil Fukalov):
[SCEV] limit recursion depth of CompareSCEVComplexity
Summary:
CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
loop) and runs almost infinite time.
Added cache of "equal" SCEV pairs to earlier cutoff of further
estimation. Recursion depth limit was also introduced as a parameter.
Reviewers: sanjoy
Subscribers: mzolotukhin, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D26389
This commit is the cause of excessive compile times on skein_block.c
(and possibly other files) during kernel builds on amd64.
We never saw the problematic behavior described in this upstream commit,
so for now it is better to revert it. An upstream bug has been filed
here: https://bugs.llvm.org/show_bug.cgi?id=32142
Reported by: mjg
MFC r314795:
Reapply r287232 from upstream llvm trunk (by Daniil Fukalov):
[SCEV] limit recursion depth of CompareSCEVComplexity
Summary:
CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
loop) and runs almost infinite time.
Added cache of "equal" SCEV pairs to earlier cutoff of further
estimation. Recursion depth limit was also introduced as a parameter.
Reviewers: sanjoy
Subscribers: mzolotukhin, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D26389
Pull in r296992 from upstream llvm trunk (by Sanjoy Das):
[SCEV] Decrease the recursion threshold for CompareValueComplexity
Fixes PR32142.
r287232 accidentally increased the recursion threshold for
CompareValueComplexity from 2 to 32. This change reverses that
change by introducing a separate flag for CompareValueComplexity's
threshold.
The latter revision fixes the excessive compile times for skein_block.c.
MFC r314907 | mmel | 2017-03-08 12:40:27 +0100 (Wed, 08 Mar 2017) | 7 lines
Unbreak ARMv6 world.
The new compiler_rt library imported with clang 4.0.0 have several fatal
issues (non-functional __udivsi3 for example) with ARM specific instrict
functions. As temporary workaround, until upstream solve these problems,
disable all thumb[1][2] related feature.
MFC r315016:
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release.
We were already very close to the last release candidate, so this is a
pretty minor update.
Relnotes: yes
MFC r316005:
Revert r314907, and pull in r298713 from upstream compiler-rt trunk (by
Weiming Zhao):
builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA.
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.
Due to this:
- use __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB
- use '.thumb' directive consistently in all affected files
- decorate all thumb functions using
DEFINE_COMPILERRT_THUMB_FUNCTION()
---------
Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 !
Reviewers: weimingz, rengolin, compnerd
Subscribers: aemerson, dim
Differential Revision: https://reviews.llvm.org/D30938
Discussed with: mmel
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Frontend')
15 files changed, 147 insertions, 94 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h index 04e6dce..b1cdb46 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h @@ -16,7 +16,6 @@ #include "clang-c/Index.h" #include "clang/AST/ASTContext.h" -#include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SourceManager.h" @@ -30,9 +29,7 @@ #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> @@ -47,7 +44,6 @@ namespace clang { class Sema; class ASTContext; class ASTReader; -class CodeCompleteConsumer; class CompilerInvocation; class CompilerInstance; class Decl; @@ -58,7 +54,6 @@ class HeaderSearch; class Preprocessor; class PCHContainerOperations; class PCHContainerReader; -class SourceManager; class TargetInfo; class FrontendAction; class ASTDeserializationListener; @@ -91,10 +86,10 @@ private: IntrusiveRefCntPtr<SourceManager> SourceMgr; std::unique_ptr<HeaderSearch> HeaderInfo; IntrusiveRefCntPtr<TargetInfo> Target; - IntrusiveRefCntPtr<Preprocessor> PP; + std::shared_ptr<Preprocessor> PP; IntrusiveRefCntPtr<ASTContext> Ctx; std::shared_ptr<TargetOptions> TargetOpts; - IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts; + std::shared_ptr<HeaderSearchOptions> HSOpts; IntrusiveRefCntPtr<ASTReader> Reader; bool HadModuleLoaderFatalFailure; @@ -113,8 +108,8 @@ private: /// Optional owned invocation, just used to make the invocation used in /// LoadFromCommandLine available. - IntrusiveRefCntPtr<CompilerInvocation> Invocation; - + std::shared_ptr<CompilerInvocation> Invocation; + // 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. @@ -363,22 +358,21 @@ public: } /// \brief Retrieve the allocator used to cache global code completions. - IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> + std::shared_ptr<GlobalCodeCompletionAllocator> getCachedCompletionAllocator() { return CachedCompletionAllocator; } CodeCompletionTUInfo &getCodeCompletionTUInfo() { if (!CCTUInfo) - CCTUInfo.reset(new CodeCompletionTUInfo( - new GlobalCodeCompletionAllocator)); + CCTUInfo = llvm::make_unique<CodeCompletionTUInfo>( + std::make_shared<GlobalCodeCompletionAllocator>()); return *CCTUInfo; } private: /// \brief Allocator used to store cached code completions. - IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> - CachedCompletionAllocator; + std::shared_ptr<GlobalCodeCompletionAllocator> CachedCompletionAllocator; std::unique_ptr<CodeCompletionTUInfo> CCTUInfo; @@ -437,9 +431,6 @@ private: bool PreambleEndsAtStartOfLine) : Buffer(Buffer), Owner(std::move(Owner)), Size(Size), PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {} - ComputedPreamble(ComputedPreamble &&C) - : Buffer(C.Buffer), Owner(std::move(C.Owner)), Size(C.Size), - PreambleEndsAtStartOfLine(C.PreambleEndsAtStartOfLine) {} }; ComputedPreamble ComputePreamble(CompilerInvocation &Invocation, unsigned MaxLines); @@ -504,12 +495,13 @@ public: const Preprocessor &getPreprocessor() const { return *PP; } Preprocessor &getPreprocessor() { return *PP; } + std::shared_ptr<Preprocessor> getPreprocessorPtr() const { return PP; } const ASTContext &getASTContext() const { return *Ctx; } ASTContext &getASTContext() { return *Ctx; } void setASTContext(ASTContext *ctx) { Ctx = ctx; } - void setPreprocessor(Preprocessor *pp); + void setPreprocessor(std::shared_ptr<Preprocessor> pp); bool hasSema() const { return (bool)TheSema; } Sema &getSema() const { @@ -709,11 +701,11 @@ public: /// remapped contents of that file. typedef std::pair<std::string, llvm::MemoryBuffer *> RemappedFile; - /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation. - static ASTUnit *create(CompilerInvocation *CI, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - bool CaptureDiagnostics, - bool UserFilesAreVolatile); + /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation. + static std::unique_ptr<ASTUnit> + create(std::shared_ptr<CompilerInvocation> CI, + IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool CaptureDiagnostics, + bool UserFilesAreVolatile); /// \brief Create a ASTUnit from an AST file. /// @@ -778,7 +770,7 @@ public: /// created ASTUnit was passed in \p Unit then the caller can check that. /// static ASTUnit *LoadFromCompilerInvocationAction( - CompilerInvocation *CI, + std::shared_ptr<CompilerInvocation> CI, std::shared_ptr<PCHContainerOperations> PCHContainerOps, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr, @@ -805,7 +797,7 @@ public: // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we // shouldn't need to specify them at construction time. static std::unique_ptr<ASTUnit> LoadFromCompilerInvocation( - CompilerInvocation *CI, + std::shared_ptr<CompilerInvocation> CI, std::shared_ptr<PCHContainerOperations> PCHContainerOps, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr, bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def index 6a4474c..964a6cc 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def @@ -1,4 +1,4 @@ -//===--- CodeGenOptions.def - Code generation option database ------ C++ -*-===// +//===--- CodeGenOptions.def - Code generation option database ----- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm. +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments. CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe. @@ -48,13 +49,12 @@ CODEGENOPT(DisableFPElim , 1, 0) ///< Set when -fomit-frame-pointer is enabl CODEGENOPT(DisableFree , 1, 0) ///< Don't free memory. CODEGENOPT(DiscardValueNames , 1, 0) ///< Discard Value Names from the IR (LLVMContext flag) CODEGENOPT(DisableGCov , 1, 0) ///< Don't run the GCov pass, for testing. -CODEGENOPT(DisableLLVMOpts , 1, 0) ///< Don't run any optimizations, for use in - ///< getting .bc files that correspond to the - ///< internal state before optimizations are - ///< done. CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get ///< the pristine IR generated by the ///< frontend. +CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers +CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental + ///< pass manager. CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled. CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls. CODEGENOPT(EmitDeclMetadata , 1, 0) ///< Emit special metadata indicating what @@ -106,9 +106,10 @@ CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enable CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf. CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero CODEGENOPT(ReciprocalMath , 1, 0) ///< Allow FP divisions to be reassociated. -CODEGENOPT(NoInline , 1, 0) ///< Set when -fno-inline is enabled. - ///< Disables use of the inline keyword. +CODEGENOPT(NoTrappingMath , 1, 0) ///< Set when -fno-trapping-math is enabled. CODEGENOPT(NoNaNsFPMath , 1, 0) ///< Assume FP arguments, results not NaN. +CODEGENOPT(FlushDenorm , 1, 0) ///< Allow FP denorm numbers to be flushed to zero +CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss. /// \brief Method of Objective-C dispatch to use. ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy) @@ -148,10 +149,16 @@ CODEGENOPT(SanitizeCoverageTraceBB, 1, 0) ///< Enable basic block tracing in ///< in sanitizer coverage. CODEGENOPT(SanitizeCoverageTraceCmp, 1, 0) ///< Enable cmp instruction tracing ///< in sanitizer coverage. +CODEGENOPT(SanitizeCoverageTraceDiv, 1, 0) ///< Enable div instruction tracing + ///< in sanitizer coverage. +CODEGENOPT(SanitizeCoverageTraceGep, 1, 0) ///< Enable GEP instruction tracing + ///< in sanitizer coverage. CODEGENOPT(SanitizeCoverage8bitCounters, 1, 0) ///< Use 8-bit frequency counters ///< in sanitizer coverage. CODEGENOPT(SanitizeCoverageTracePC, 1, 0) ///< Enable PC tracing ///< in sanitizer coverage. +CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with guard + ///< in sanitizer coverage. CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers. CODEGENOPT(SimplifyLibCalls , 1, 1) ///< Set when -fbuiltin is enabled. CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float. @@ -191,6 +198,9 @@ CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should contain CODEGENOPT(DebugExplicitImport, 1, 0) ///< Whether or not debug info should ///< contain explicit imports for ///< anonymous namespaces +CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the + ///< skeleton CU to allow for symbolication + ///< of inline stack frames without .dwo files. CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists. @@ -224,10 +234,10 @@ VALUE_CODEGENOPT(DwarfVersion, 3, 0) CODEGENOPT(EmitCodeView, 1, 0) /// The kind of inlining to perform. -ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NoInlining) +ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining) // Vector functions library to use. -ENUM_CODEGENOPT(VecLib, VectorLibrary, 1, NoLibrary) +ENUM_CODEGENOPT(VecLib, VectorLibrary, 2, NoLibrary) /// The default TLS model to use. ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel) @@ -236,6 +246,16 @@ ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel) /// filename) VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0) +/// Whether to report the hotness of the code region for optimization remarks. +CODEGENOPT(DiagnosticsWithHotness, 1, 0) + +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + +/// Whether we should use the undefined behaviour optimization for control flow +/// paths that reach the end of a function without executing a required return. +CODEGENOPT(StrictReturn, 1, 1) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h index 4bc3120..52bd1c5 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h @@ -44,17 +44,18 @@ protected: class CodeGenOptions : public CodeGenOptionsBase { public: enum InliningMethod { - NoInlining, // Perform no inlining whatsoever. NormalInlining, // Use the standard function inlining pass. OnlyHintInlining, // Inline only (implicitly) hinted functions. OnlyAlwaysInlining // Only run the always inlining pass. }; enum VectorLibrary { - NoLibrary, // Don't use any vector library. - Accelerate // Use the Accelerate framework. + NoLibrary, // Don't use any vector library. + Accelerate, // Use the Accelerate framework. + SVML // Intel short vector math library. }; + enum ObjCDispatchMethodKind { Legacy = 0, NonLegacy = 1, @@ -97,9 +98,13 @@ public: /// The code model to use (-mcmodel). std::string CodeModel; - /// The filename with path we use for coverage files. The extension will be - /// replaced. - std::string CoverageFile; + /// The filename with path we use for coverage data files. The runtime + /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP + /// environment variables. + std::string CoverageDataFile; + + /// The filename with path we use for coverage notes files. + std::string CoverageNotesFile; /// The version string to put into coverage files. char CoverageVersion[4]; @@ -119,6 +124,9 @@ public: /// The ABI to use for passing floating point arguments. std::string FloatABI; + /// The floating-point denormal mode to use. + std::string FPDenormalMode; + /// The float precision limit to use, if non-empty. std::string LimitFloatPrecision; @@ -172,6 +180,10 @@ public: /// object file. std::vector<std::string> CudaGpuBinaryFileNames; + /// The name of the file to which the backend should save YAML optimization + /// records. + std::string OptRecordFile; + /// 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 diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h index 1228cf4..3ebbc61 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInstance.h @@ -11,11 +11,12 @@ #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ #include "clang/AST/ASTConsumer.h" -#include "clang/Frontend/PCHContainerOperations.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Frontend/CompilerInvocation.h" +#include "clang/Frontend/PCHContainerOperations.h" #include "clang/Frontend/Utils.h" +#include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/ModuleLoader.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" @@ -35,7 +36,6 @@ class TimerGroup; namespace clang { class ASTContext; -class ASTConsumer; class ASTReader; class CodeCompleteConsumer; class DiagnosticsEngine; @@ -70,7 +70,7 @@ class TargetInfo; /// and a long form that takes explicit instances of any required objects. class CompilerInstance : public ModuleLoader { /// The options used in this compiler instance. - IntrusiveRefCntPtr<CompilerInvocation> Invocation; + std::shared_ptr<CompilerInvocation> Invocation; /// The diagnostics engine instance. IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; @@ -91,11 +91,14 @@ class CompilerInstance : public ModuleLoader { IntrusiveRefCntPtr<SourceManager> SourceMgr; /// The preprocessor. - IntrusiveRefCntPtr<Preprocessor> PP; + std::shared_ptr<Preprocessor> PP; /// The AST context. IntrusiveRefCntPtr<ASTContext> Context; + /// An optional sema source that will be attached to sema. + IntrusiveRefCntPtr<ExternalSemaSource> ExternalSemaSrc; + /// The AST consumer. std::unique_ptr<ASTConsumer> Consumer; @@ -225,7 +228,7 @@ public: } /// setInvocation - Replace the current invocation. - void setInvocation(CompilerInvocation *Value); + void setInvocation(std::shared_ptr<CompilerInvocation> Value); /// \brief Indicates whether we should (re)build the global module index. bool shouldBuildGlobalModuleIndex() const; @@ -285,6 +288,9 @@ public: const HeaderSearchOptions &getHeaderSearchOpts() const { return Invocation->getHeaderSearchOpts(); } + std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const { + return Invocation->getHeaderSearchOptsPtr(); + } LangOptions &getLangOpts() { return *Invocation->getLangOpts(); @@ -430,13 +436,14 @@ public: return *PP; } + std::shared_ptr<Preprocessor> getPreprocessorPtr() { return PP; } + void resetAndLeakPreprocessor() { - BuryPointer(PP.get()); - PP.resetWithoutRelease(); + BuryPointer(new std::shared_ptr<Preprocessor>(PP)); } /// Replace the current preprocessor. - void setPreprocessor(Preprocessor *Value); + void setPreprocessor(std::shared_ptr<Preprocessor> Value); /// } /// @name ASTContext @@ -650,7 +657,7 @@ public: StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, - ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, + ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex); @@ -774,6 +781,8 @@ public: void addDependencyCollector(std::shared_ptr<DependencyCollector> Listener) { DependencyCollectors.push_back(std::move(Listener)); } + + void setExternalSemaSource(IntrusiveRefCntPtr<ExternalSemaSource> ESS); }; } // 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 0d5008e..cef7f73 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h @@ -13,29 +13,29 @@ #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/LangOptions.h" -#include "clang/Basic/TargetOptions.h" #include "clang/Frontend/CodeGenOptions.h" #include "clang/Frontend/DependencyOutputOptions.h" #include "clang/Frontend/FrontendOptions.h" #include "clang/Frontend/LangStandard.h" #include "clang/Frontend/MigratorOptions.h" #include "clang/Frontend/PreprocessorOutputOptions.h" -#include "clang/Lex/HeaderSearchOptions.h" -#include "clang/Lex/PreprocessorOptions.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" #include <string> -#include <vector> namespace llvm { +class Triple; + namespace opt { class ArgList; } } namespace clang { +class PreprocessorOptions; +class HeaderSearchOptions; +class TargetOptions; +class LangOptions; class CompilerInvocation; class DiagnosticsEngine; @@ -48,9 +48,10 @@ class DiagnosticsEngine; /// report the error(s). bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args, DiagnosticsEngine *Diags = nullptr, - bool DefaultDiagColor = true); + bool DefaultDiagColor = true, + bool DefaultShowOpt = true); -class CompilerInvocationBase : public RefCountedBase<CompilerInvocation> { +class CompilerInvocationBase { void operator=(const CompilerInvocationBase &) = delete; public: @@ -64,10 +65,10 @@ public: IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts; /// Options controlling the \#include directive. - IntrusiveRefCntPtr<HeaderSearchOptions> HeaderSearchOpts; + std::shared_ptr<HeaderSearchOptions> HeaderSearchOpts; /// Options controlling the preprocessor (aside from \#include handling). - IntrusiveRefCntPtr<PreprocessorOptions> PreprocessorOpts; + std::shared_ptr<PreprocessorOptions> PreprocessorOpts; CompilerInvocationBase(); ~CompilerInvocationBase(); @@ -88,7 +89,13 @@ public: const HeaderSearchOptions &getHeaderSearchOpts() const { return *HeaderSearchOpts; } + std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const { + return HeaderSearchOpts; + } + std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr() { + return PreprocessorOpts; + } PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; } const PreprocessorOptions &getPreprocessorOpts() const { return *PreprocessorOpts; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h index c372fdd..2588feb 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/DiagnosticRenderer.h @@ -19,7 +19,6 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/PointerUnion.h" 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 0cbacbb..20fddc4 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h @@ -88,14 +88,17 @@ public: static std::unique_ptr<raw_pwrite_stream> ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile, std::string &Sysroot, std::string &OutputFile); + + bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; }; class GenerateModuleAction : public ASTFrontendAction { - clang::Module *Module; - const FileEntry *ModuleMapForUniquing; - bool IsSystem; - + virtual std::unique_ptr<raw_pwrite_stream> + CreateOutputFile(CompilerInstance &CI, StringRef InFile) = 0; + protected: + bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; @@ -104,22 +107,31 @@ protected: } bool hasASTFileSupport() const override { return false; } +}; + +class GenerateModuleFromModuleMapAction : public GenerateModuleAction { + clang::Module *Module = nullptr; + const FileEntry *ModuleMapForUniquing = nullptr; + bool IsSystem = false; + +private: + bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + + std::unique_ptr<raw_pwrite_stream> + CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; public: - GenerateModuleAction(const FileEntry *ModuleMap = nullptr, - bool IsSystem = false) - : ASTFrontendAction(), ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem) - { } + GenerateModuleFromModuleMapAction() {} + GenerateModuleFromModuleMapAction(const FileEntry *ModuleMap, bool IsSystem) + : ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem) {} +}; +class GenerateModuleInterfaceAction : public GenerateModuleAction { +private: bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; - /// \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. std::unique_ptr<raw_pwrite_stream> - ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile, - std::string &Sysroot, std::string &OutputFile); + CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; }; class SyntaxOnlyAction : public ASTFrontendAction { @@ -138,6 +150,7 @@ class DumpModuleInfoAction : public ASTFrontendAction { protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; + bool BeginInvocation(CompilerInstance &CI) override; void ExecuteAction() override; public: diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h index a75523f..9c960bb 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h @@ -40,7 +40,9 @@ namespace frontend { EmitCodeGenOnly, ///< Generate machine code, but don't emit anything. EmitObj, ///< Emit a .o file. FixIt, ///< Parse and apply any fixits to the source. - GenerateModule, ///< Generate pre-compiled module. + GenerateModule, ///< Generate pre-compiled module from a module map. + GenerateModuleInterface,///< Generate pre-compiled module from a C++ module + ///< interface file. GeneratePCH, ///< Generate pre-compiled header. GeneratePTH, ///< Generate pre-tokenized header. InitOnly, ///< Only execute frontend initialization. @@ -241,7 +243,7 @@ public: std::vector<std::string> Plugins; /// The list of module file extensions. - std::vector<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions; + std::vector<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions; /// \brief The list of module map files to load before processing the input. std::vector<std::string> ModuleMapFiles; @@ -271,6 +273,9 @@ public: // included by this file. std::string FindPchSource; + /// Filename to write statistics to. + std::string StatsFile; + public: FrontendOptions() : DisableFree(false), RelocatablePCH(false), ShowHelp(false), diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h index ecab630..9d7ee08 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/FrontendPluginRegistry.h @@ -13,9 +13,6 @@ #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/LangStandards.def b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def index a303693..06fe1a3 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def @@ -81,7 +81,7 @@ LANGSTANDARD(iso9899_2011, "iso9899:2011", "ISO C 2011", LineComment | C99 | C11 | Digraphs | HexFloat) LANGSTANDARD(iso9899_201x, - "iso9899:2011", "ISO C 2011", + "iso9899:201x", "ISO C 2011", LineComment | C99 | C11 | Digraphs | HexFloat) LANGSTANDARD(gnu11, "gnu11", diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/PCHContainerOperations.h b/contrib/llvm/tools/clang/include/clang/Frontend/PCHContainerOperations.h index 0c1b28e..d323fb3 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/PCHContainerOperations.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/PCHContainerOperations.h @@ -17,7 +17,6 @@ namespace llvm { class raw_pwrite_stream; -class BitstreamReader; } using llvm::StringRef; @@ -63,10 +62,8 @@ public: /// Equivalent to the format passed to -fmodule-format= virtual StringRef getFormat() const = 0; - /// Initialize an llvm::BitstreamReader with the serialized AST inside - /// the PCH container Buffer. - virtual void ExtractPCH(llvm::MemoryBufferRef Buffer, - llvm::BitstreamReader &StreamFile) const = 0; + /// Returns the serialized AST inside the PCH container Buffer. + virtual StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const = 0; }; /// Implements write operations for a raw pass-through PCH container. @@ -87,9 +84,8 @@ class RawPCHContainerWriter : public PCHContainerWriter { class RawPCHContainerReader : public PCHContainerReader { StringRef getFormat() const override { return "raw"; } - /// Initialize an llvm::BitstreamReader with Buffer. - void ExtractPCH(llvm::MemoryBufferRef Buffer, - llvm::BitstreamReader &StreamFile) const override; + /// Simply returns the buffer contained in Buffer. + StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const override; }; /// A registry of PCHContainerWriter and -Reader objects for different formats. diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h index f86c490..3261b66 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOutputOptions.h @@ -22,6 +22,7 @@ public: unsigned UseLineDirectives : 1; ///< Use \#line instead of GCC-style \# N. unsigned ShowMacroComments : 1; ///< Show comments, even in macros. unsigned ShowMacros : 1; ///< Print macro definitions. + unsigned ShowIncludeDirectives : 1; ///< Print includes, imports etc. within preprocessed output. unsigned RewriteIncludes : 1; ///< Preprocess include directives only. public: @@ -32,6 +33,7 @@ public: UseLineDirectives = 0; ShowMacroComments = 0; ShowMacros = 0; + ShowIncludeDirectives = 0; RewriteIncludes = 0; } }; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticReader.h b/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticReader.h index 3db362b..0747984 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticReader.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/SerializedDiagnosticReader.h @@ -11,7 +11,6 @@ #define LLVM_CLANG_FRONTEND_SERIALIZED_DIAGNOSTIC_READER_H_ #include "clang/Basic/LLVM.h" -#include "llvm/ADT/ArrayRef.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/ErrorOr.h" diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h index d41f15a..9b108c2 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h @@ -107,6 +107,8 @@ protected: const SourceManager &SM) override; private: + void emitFilename(StringRef Filename, const SourceManager &SM); + void emitSnippetAndCaret(SourceLocation Loc, DiagnosticsEngine::Level Level, SmallVectorImpl<CharSourceRange>& Ranges, ArrayRef<FixItHint> Hints, diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h index cf943a5..0ee4684 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h +++ b/contrib/llvm/tools/clang/include/clang/Frontend/Utils.h @@ -128,11 +128,11 @@ class ModuleDependencyCollector : public DependencyCollector { llvm::StringMap<std::string> SymLinkMap; bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result); - std::error_code copyToRoot(StringRef Src); + std::error_code copyToRoot(StringRef Src, StringRef Dst = ""); public: StringRef getDest() { return DestDir; } bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; } - void addFile(StringRef Filename); + void addFile(StringRef Filename, StringRef FileDst = ""); void addFileMapping(StringRef VPath, StringRef RPath) { VFSWriter.addFileMapping(VPath, RPath); } @@ -184,10 +184,10 @@ createChainedIncludesSource(CompilerInstance &CI, /// /// \return A CompilerInvocation, or 0 if none was built for the given /// argument vector. -CompilerInvocation * +std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(ArrayRef<const char *> Args, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags = - IntrusiveRefCntPtr<DiagnosticsEngine>()); + IntrusiveRefCntPtr<DiagnosticsEngine> Diags = + IntrusiveRefCntPtr<DiagnosticsEngine>()); /// Return the value of the last argument as an integer, or a default. If Diags /// is non-null, emits an error if the argument is given, but non-integral. |