aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h4
-rw-r--r--include/clang/Frontend/ASTUnit.h48
-rw-r--r--include/clang/Frontend/CodeGenOptions.def346
-rw-r--r--include/clang/Frontend/CodeGenOptions.h307
-rw-r--r--include/clang/Frontend/CompilerInstance.h15
-rw-r--r--include/clang/Frontend/CompilerInvocation.h23
-rw-r--r--include/clang/Frontend/FrontendAction.h20
-rw-r--r--include/clang/Frontend/FrontendActions.h18
-rw-r--r--include/clang/Frontend/FrontendDiagnostic.h15
-rw-r--r--include/clang/Frontend/FrontendOptions.h9
-rw-r--r--include/clang/Frontend/LangStandards.def3
-rw-r--r--include/clang/Frontend/PCHContainerOperations.h106
-rw-r--r--include/clang/Frontend/PrecompiledPreamble.h26
-rw-r--r--include/clang/Frontend/Utils.h19
14 files changed, 100 insertions, 859 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index 2a13527df135..c2144da054f0 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -50,10 +50,6 @@ std::unique_ptr<ASTConsumer> CreateASTDeclNodeLister();
// function declarations to stderr.
std::unique_ptr<ASTConsumer> CreateASTViewer();
-// DeclContext printer: prints out the DeclContext tree in human-readable form
-// to stderr; this is intended for debugging.
-std::unique_ptr<ASTConsumer> CreateDeclContextPrinter();
-
} // end clang namespace
#endif
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index ba145965462f..d0b532cf2d34 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -51,6 +51,11 @@ namespace llvm {
class MemoryBuffer;
+namespace vfs {
+
+class FileSystem;
+
+} // namespace vfs
} // namespace llvm
namespace clang {
@@ -75,12 +80,6 @@ class PreprocessorOptions;
class Sema;
class TargetInfo;
-namespace vfs {
-
-class FileSystem;
-
-} // namespace vfs
-
/// \brief Enumerates the available scopes for skipping function bodies.
enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
@@ -365,12 +364,12 @@ private:
bool Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS);
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
std::unique_ptr<llvm::MemoryBuffer> getMainBufferWithPrecompiledPreamble(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
CompilerInvocation &PreambleInvocationIn,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild = true,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool AllowRebuild = true,
unsigned MaxLines = 0);
void RealizeTopLevelDeclsFromPreamble();
@@ -698,17 +697,17 @@ private:
/// of this translation unit should be precompiled, to improve the performance
/// of reparsing. Set to zero to disable preambles.
///
- /// \param VFS - A vfs::FileSystem to be used for all file accesses. Note that
- /// preamble is saved to a temporary directory on a RealFileSystem, so in order
- /// for it to be loaded correctly, VFS should have access to it(i.e., be an
- /// overlay over RealFileSystem).
+ /// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
+ /// Note that preamble is saved to a temporary directory on a RealFileSystem,
+ /// so in order for it to be loaded correctly, VFS should have access to
+ /// it(i.e., be an overlay over RealFileSystem).
///
/// \returns \c true if a catastrophic failure occurred (which means that the
/// \c ASTUnit itself is invalid), or \c false otherwise.
bool LoadFromCompilerInvocation(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
unsigned PrecompilePreambleAfterNParses,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS);
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
public:
/// Create an ASTUnit from a source file, via a CompilerInvocation
@@ -798,10 +797,11 @@ public:
/// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
/// mainly to allow the caller to see the diagnostics.
///
- /// \param VFS - A vfs::FileSystem to be used for all file accesses. Note that
- /// preamble is saved to a temporary directory on a RealFileSystem, so in order
- /// for it to be loaded correctly, VFS should have access to it(i.e., be an
- /// overlay over RealFileSystem). RealFileSystem will be used if \p VFS is nullptr.
+ /// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
+ /// Note that preamble is saved to a temporary directory on a RealFileSystem,
+ /// so in order for it to be loaded correctly, VFS should have access to
+ /// it(i.e., be an overlay over RealFileSystem). RealFileSystem will be used
+ /// if \p VFS is nullptr.
///
// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
// shouldn't need to specify them at construction time.
@@ -823,22 +823,22 @@ public:
bool ForSerialization = false,
llvm::Optional<StringRef> ModuleFormat = llvm::None,
std::unique_ptr<ASTUnit> *ErrAST = nullptr,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// Reparse the source files using the same command-line options that
/// were originally used to produce this translation unit.
///
- /// \param VFS - A vfs::FileSystem to be used for all file accesses. Note that
- /// preamble is saved to a temporary directory on a RealFileSystem, so in order
- /// for it to be loaded correctly, VFS should give an access to this(i.e. be an
- /// overlay over RealFileSystem). FileMgr->getVirtualFileSystem() will be used if
- /// \p VFS is nullptr.
+ /// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
+ /// Note that preamble is saved to a temporary directory on a RealFileSystem,
+ /// so in order for it to be loaded correctly, VFS should give an access to
+ /// this(i.e. be an overlay over RealFileSystem).
+ /// FileMgr->getVirtualFileSystem() will be used if \p VFS is nullptr.
///
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
ArrayRef<RemappedFile> RemappedFiles = None,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// Free data that will be re-generated on the next parse.
///
diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def
deleted file mode 100644
index a7e71f7ac016..000000000000
--- a/include/clang/Frontend/CodeGenOptions.def
+++ /dev/null
@@ -1,346 +0,0 @@
-//===--- CodeGenOptions.def - Code generation option database ----- 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 code generation options. Users of this file
-// must define the CODEGENOPT macro to make use of this information.
-// Optionally, the user may also define ENUM_CODEGENOPT (for options
-// that have enumeration type and VALUE_CODEGENOPT is a code
-// generation option that describes a value rather than a flag.
-//
-//===----------------------------------------------------------------------===//
-#ifndef CODEGENOPT
-# error Define the CODEGENOPT macro to handle language options
-#endif
-
-#ifndef VALUE_CODEGENOPT
-# define VALUE_CODEGENOPT(Name, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
-#endif
-
-#ifndef ENUM_CODEGENOPT
-# define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
-#endif
-
-CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
- llvm::DebugCompressionType::None)
-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.
-CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
-CODEGENOPT(ControlFlowGuard , 1, 0) ///< -cfguard
-CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
-CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files.
-CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit block before the body blocks in GCNO files.
-CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors.
-CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or __cxa_atexit to register global destructors.
-CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker
- ///< aliases to base ctors when possible.
-CODEGENOPT(DataSections , 1, 0) ///< Set when -fdata-sections is enabled.
-CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for -funique-section-names.
-CODEGENOPT(DisableFPElim , 1, 0) ///< Set when -fomit-frame-pointer is enabled.
-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(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(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0
-CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
- ///< pass manager.
-CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
- ///< pass manager.
-CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled.
-CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls.
-CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from
- ///< escaping blocks.
-CODEGENOPT(EmitDeclMetadata , 1, 0) ///< Emit special metadata indicating what
- ///< Decl* various IR entities came from.
- ///< Only useful when running CodeGen as a
- ///< subroutine.
-CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata.
-CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA.
-CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO.
-CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
-CODEGENOPT(EmulatedTLS , 1, 0) ///< Set by default or -f[no-]emulated-tls.
-CODEGENOPT(ExplicitEmulatedTLS , 1, 0) ///< Set if -f[no-]emulated-tls is used.
-/// Embed Bitcode mode (off/all/bitcode/marker).
-ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off)
-CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard variables
- ///< are required.
-CODEGENOPT(FunctionSections , 1, 0) ///< Set when -ffunction-sections is enabled.
-CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
- ///< enabled.
-CODEGENOPT(InstrumentFunctionsAfterInlining , 1, 0) ///< Set when
- ///< -finstrument-functions-after-inlining is enabled.
-CODEGENOPT(InstrumentFunctionEntryBare , 1, 0) ///< Set when
- ///< -finstrument-function-entry-bare is enabled.
-CODEGENOPT(CFProtectionReturn , 1, 0) ///< if -fcf-protection is
- ///< set to full or return.
-CODEGENOPT(CFProtectionBranch , 1, 0) ///< if -fcf-protection is
- ///< set to full or branch.
-CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
- ///< enabled.
-CODEGENOPT(StackSizeSection , 1, 0) ///< Set when -fstack-size-section is enabled.
-
-///< Set when -fxray-always-emit-customevents is enabled.
-CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
-
-///< Set when -fxray-always-emit-typedevents is enabled.
-CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0)
-
-///< Set the minimum number of instructions in a function to determine selective
-///< XRay instrumentation.
-VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)
-
-CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled.
-CODEGENOPT(CallFEntry , 1, 0) ///< Set when -mfentry is enabled.
-CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions to
- ///< be generated.
-CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
- ///< compile step.
-CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
- ///< compile step.
-CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
- ///< program vtable opt).
-CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which can
- ///< be used with an incremental
- ///< linker.
-CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
-CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
-CODEGENOPT(MSVolatile , 1, 0) ///< Set when /volatile:ms is enabled.
-CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
- ///< enabled.
-CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
-CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
- ///< enabled.
-CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled.
-CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled.
-CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf.
-CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero
-CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is defined.
-CODEGENOPT(Reassociate , 1, 0) ///< Allow reassociation of FP math ops
-CODEGENOPT(ReciprocalMath , 1, 0) ///< Allow FP divisions to be reassociated.
-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
-
-/// When false, this attempts to generate code as if the result of an
-/// overflowing conversion matches the overflowing behavior of a target's native
-/// float-to-int conversion instructions.
-CODEGENOPT(StrictFloatCastOverflow, 1, 1)
-
-CODEGENOPT(UniformWGSize , 1, 0) ///< -cl-uniform-work-group-size
-CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
-/// Method of Objective-C dispatch to use.
-ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
-CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is
- ///< enabled.
-
-VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
-VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
-
-/// Choose profile instrumenation kind or no instrumentation.
-ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
-/// Choose profile kind for PGO use compilation.
-ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileNone)
-CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
- ///< enable code coverage analysis.
-CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
- ///< regions.
-
- /// If -fpcc-struct-return or -freg-struct-return is specified.
-ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, SRCK_Default)
-
-CODEGENOPT(RelaxAll , 1, 0) ///< Relax all machine code instructions.
-CODEGENOPT(RelaxedAliasing , 1, 0) ///< Set when -fno-strict-aliasing is enabled.
-CODEGENOPT(StructPathTBAA , 1, 0) ///< Whether or not to use struct-path TBAA.
-CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-path TBAA.
-CODEGENOPT(SaveTempLabels , 1, 0) ///< Save temporary labels.
-CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection
- ///< in AddressSanitizer
-CODEGENOPT(SanitizeAddressPoisonClassMemberArrayNewCookie, 1,
- 0) ///< Enable poisoning operator new[] which is not a replaceable
- ///< global allocation function in AddressSanitizer
-CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead stripping
- ///< of globals in AddressSanitizer
-CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
- ///< MemorySanitizer
-CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
- ///< in MemorySanitizer
-CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
-CODEGENOPT(SanitizeMinimalRuntime, 1, 0) ///< Use "_minimal" sanitizer runtime for
- ///< diagnostics.
-CODEGENOPT(SanitizeCfiICallGeneralizePointers, 1, 0) ///< Generalize pointer types in
- ///< CFI icall function signatures
-CODEGENOPT(SanitizeCoverageType, 2, 0) ///< Type of sanitizer coverage
- ///< instrumentation.
-CODEGENOPT(SanitizeCoverageIndirectCalls, 1, 0) ///< Enable sanitizer coverage
- ///< for indirect calls.
-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(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit counters.
-CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table.
-CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
-CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth tracing
-CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
-CODEGENOPT(SimplifyLibCalls , 1, 1) ///< Set when -fbuiltin is enabled.
-CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.
-CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable fine-grained bitfield accesses.
-CODEGENOPT(StrictEnums , 1, 0) ///< Optimize based on strict enum definition.
-CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict vtable pointers
-CODEGENOPT(TimePasses , 1, 0) ///< Set when -ftime-report is enabled.
-CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled.
-CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled.
-CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled.
-CODEGENOPT(UnsafeFPMath , 1, 0) ///< Allow unsafe floating point optzns.
-CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables.
-CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
-CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer.
-CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
-
- /// Attempt to use register sized accesses to bit-fields in structures, when
- /// possible.
-CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
-
-CODEGENOPT(VerifyModule , 1, 1) ///< Control whether the module should be run
- ///< through the LLVM Verifier.
-
-CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to force stack
- ///< realignment.
-CODEGENOPT(UseInitArray , 1, 0) ///< Control whether to use .init_array or
- ///< .ctors.
-VALUE_CODEGENOPT(StackAlignment , 32, 0) ///< Overrides default stack
- ///< alignment, if not 0.
-VALUE_CODEGENOPT(StackProbeSize , 32, 4096) ///< Overrides default stack
- ///< probe size, even if 0.
-CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
-CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
- ///< in debug info.
-
-CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should contain
- ///< external references to a PCH or module.
-
-CODEGENOPT(DebugExplicitImport, 1, 0) ///< Whether or not debug info should
- ///< contain explicit imports for
- ///< anonymous namespaces
-CODEGENOPT(EnableSplitDwarf, 1, 0) ///< Whether to enable split DWARF
-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(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
- ///< template parameter descriptions in
- ///< forward declarations (versus just
- ///< including them in the name).
-
-CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
-
-CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
- /// vtable optimization.
-
-/// Whether to use public LTO visibility for entities in std and stdext
-/// namespaces. This is enabled by clang-cl's /MT and /MTd flags.
-CODEGENOPT(LTOVisibilityPublicStd, 1, 0)
-
-/// The user specified number of registers to be used for integral arguments,
-/// or 0 if unspecified.
-VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)
-
-/// The lower bound for a buffer to be considered for stack protection.
-VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
-
-/// The kind of generated debug info.
-ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 3, codegenoptions::NoDebugInfo)
-
-/// Whether to generate macro debug info.
-CODEGENOPT(MacroDebugInfo, 1, 0)
-
-/// Tune the debug info for this debugger.
-ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 2,
- llvm::DebuggerKind::Default)
-
-/// Dwarf version. Version zero indicates to LLVM that no DWARF should be
-/// emitted.
-VALUE_CODEGENOPT(DwarfVersion, 3, 0)
-
-/// Whether we should emit CodeView debug information. It's possible to emit
-/// CodeView and DWARF into the same object.
-CODEGENOPT(EmitCodeView, 1, 0)
-
-/// The kind of inlining to perform.
-ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
-
-// Vector functions library to use.
-ENUM_CODEGENOPT(VecLib, VectorLibrary, 2, NoLibrary)
-
-/// The default TLS model to use.
-ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
-
-/// Number of path components to strip when emitting checks. (0 == full
-/// filename)
-VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)
-
-/// Whether to report the hotness of the code region for optimization remarks.
-CODEGENOPT(DiagnosticsWithHotness, 1, 0)
-
-/// The minimum hotness value a diagnostic needs in order to be included in
-/// optimization diagnostics.
-VALUE_CODEGENOPT(DiagnosticsHotnessThreshold, 32, 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)
-
-/// Whether emit extra debug info for sample pgo profile collection.
-CODEGENOPT(DebugInfoForProfiling, 1, 0)
-
-/// Whether 3-component vector type is preserved.
-CODEGENOPT(PreserveVec3Type, 1, 0)
-
-/// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
-CODEGENOPT(GnuPubnames, 1, 0)
-
-CODEGENOPT(NoPLT, 1, 0)
-
-/// Whether to embed source in DWARF debug line section.
-CODEGENOPT(EmbedSource, 1, 0)
-
-/// Whether to emit all vtables
-CODEGENOPT(ForceEmitVTables, 1, 0)
-
-/// Whether to emit an address-significance table into the object file.
-CODEGENOPT(Addrsig, 1, 0)
-
-
-#undef CODEGENOPT
-#undef ENUM_CODEGENOPT
-#undef VALUE_CODEGENOPT
-
diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h
deleted file mode 100644
index a6d061acf0f4..000000000000
--- a/include/clang/Frontend/CodeGenOptions.h
+++ /dev/null
@@ -1,307 +0,0 @@
-//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the CodeGenOptions interface.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
-#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
-
-#include "clang/Basic/DebugInfoOptions.h"
-#include "clang/Basic/Sanitizers.h"
-#include "clang/Basic/XRayInstr.h"
-#include "llvm/Support/CodeGen.h"
-#include "llvm/Support/Regex.h"
-#include "llvm/Target/TargetOptions.h"
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-namespace clang {
-
-/// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
-/// that this large collection of bitfields is a trivial class type.
-class CodeGenOptionsBase {
-public:
-#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default)
-#include "clang/Frontend/CodeGenOptions.def"
-
-protected:
-#define CODEGENOPT(Name, Bits, Default)
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "clang/Frontend/CodeGenOptions.def"
-};
-
-/// CodeGenOptions - Track various options which control how the code
-/// is optimized and passed to the backend.
-class CodeGenOptions : public CodeGenOptionsBase {
-public:
- enum InliningMethod {
- 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.
- SVML // Intel short vector math library.
- };
-
-
- enum ObjCDispatchMethodKind {
- Legacy = 0,
- NonLegacy = 1,
- Mixed = 2
- };
-
- enum TLSModel {
- GeneralDynamicTLSModel,
- LocalDynamicTLSModel,
- InitialExecTLSModel,
- LocalExecTLSModel
- };
-
- /// Clang versions with different platform ABI conformance.
- enum class ClangABI {
- /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
- /// (SVN r257626). This causes <1 x long long> to be passed in an
- /// integer register instead of an SSE register on x64_64.
- Ver3_8,
-
- /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
- /// (SVN r291814). This causes move operations to be ignored when
- /// determining whether a class type can be passed or returned directly.
- Ver4,
-
- /// Conform to the underlying platform's C and C++ ABIs as closely
- /// as we can.
- Latest
- };
-
- enum StructReturnConventionKind {
- SRCK_Default, // No special option was passed.
- SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
- SRCK_InRegs // Small structs in registers (-freg-struct-return).
- };
-
- enum ProfileInstrKind {
- ProfileNone, // Profile instrumentation is turned off.
- ProfileClangInstr, // Clang instrumentation to generate execution counts
- // to use with PGO.
- ProfileIRInstr, // IR level PGO instrumentation in LLVM.
- };
-
- enum EmbedBitcodeKind {
- Embed_Off, // No embedded bitcode.
- Embed_All, // Embed both bitcode and commandline in the output.
- Embed_Bitcode, // Embed just the bitcode in the output.
- Embed_Marker // Embed a marker as a placeholder for bitcode.
- };
-
- /// The code model to use (-mcmodel).
- std::string CodeModel;
-
- /// 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];
-
- /// Enable additional debugging information.
- std::string DebugPass;
-
- /// The string to embed in debug information as the current working directory.
- std::string DebugCompilationDir;
-
- /// The string to embed in the debug information for the compile unit, if
- /// non-empty.
- std::string DwarfDebugFlags;
-
- std::map<std::string, std::string> DebugPrefixMap;
-
- /// 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;
-
- struct BitcodeFileToLink {
- /// The filename of the bitcode file to link in.
- std::string Filename;
- /// If true, we set attributes functions in the bitcode library according to
- /// our CodeGenOptions, much as we set attrs on functions that we generate
- /// ourselves.
- bool PropagateAttrs = false;
- /// If true, we use LLVM module internalizer.
- bool Internalize = false;
- /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
- unsigned LinkFlags = 0;
- };
-
- /// The files specified here are linked in to the module before optimizations.
- std::vector<BitcodeFileToLink> LinkBitcodeFiles;
-
- /// The user provided name for the "main file", if non-empty. This is useful
- /// in situations where the input file name does not match the original input
- /// file, for example with -save-temps.
- std::string MainFileName;
-
- /// The name for the split debug info file that we'll break out. This is used
- /// in the backend for setting the name in the skeleton cu.
- std::string SplitDwarfFile;
-
- /// The name of the relocation model to use.
- llvm::Reloc::Model RelocationModel;
-
- /// The thread model to use
- std::string ThreadModel;
-
- /// If not an empty string, trap intrinsics are lowered to calls to this
- /// function instead of to trap instructions.
- std::string TrapFuncName;
-
- /// A list of dependent libraries.
- std::vector<std::string> DependentLibraries;
-
- /// A list of linker options to embed in the object file.
- std::vector<std::string> LinkerOptions;
-
- /// Name of the profile file to use as output for -fprofile-instr-generate
- /// and -fprofile-generate.
- std::string InstrProfileOutput;
-
- /// 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 ProfileInstrumentUsePath;
-
- /// Name of the function summary index file to use for ThinLTO function
- /// importing.
- std::string ThinLTOIndexFile;
-
- /// Name of a file that can optionally be written with minimized bitcode
- /// to be used as input for the ThinLTO thin link step, which only needs
- /// the summary and module symbol table (and not, e.g. any debug metadata).
- std::string ThinLinkBitcodeFile;
-
- /// Prefix to use for -save-temps output.
- std::string SaveTempsFilePrefix;
-
- /// Name of file passed with -fcuda-include-gpubinary option to forward to
- /// CUDA runtime back-end for incorporating them into host-side object file.
- std::string CudaGpuBinaryFileName;
-
- /// 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
- /// 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;
-
- /// Set of files defining the rules for the symbol rewriting.
- std::vector<std::string> RewriteMapFiles;
-
- /// Set of sanitizer checks that are non-fatal (i.e. execution should be
- /// continued when possible).
- SanitizerSet SanitizeRecover;
-
- /// Set of sanitizer checks that trap rather than diagnose.
- SanitizerSet SanitizeTrap;
-
- /// List of backend command-line options for -fembed-bitcode.
- std::vector<uint8_t> CmdArgs;
-
- /// A list of all -fno-builtin-* function names (e.g., memset).
- std::vector<std::string> NoBuiltinFuncs;
-
- std::vector<std::string> Reciprocals;
-
- /// The preferred width for auto-vectorization transforms. This is intended to
- /// override default transforms based on the width of the architected vector
- /// registers.
- std::string PreferVectorWidth;
-
- /// Set of XRay instrumentation kinds to emit.
- XRayInstrSet XRayInstrumentationBundle;
-
-public:
- // Define accessors/mutators for code generation options of enumeration type.
-#define CODEGENOPT(Name, Bits, Default)
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
- Type get##Name() const { return static_cast<Type>(Name); } \
- void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
-#include "clang/Frontend/CodeGenOptions.def"
-
- CodeGenOptions();
-
- /// Is this a libc/libm function that is no longer recognized as a
- /// builtin because a -fno-builtin-* option has been specified?
- bool isNoBuiltinFunc(const char *Name) const;
-
- const std::vector<std::string> &getNoBuiltinFuncs() const {
- return NoBuiltinFuncs;
- }
-
- /// Check if Clang profile instrumenation is on.
- bool hasProfileClangInstr() const {
- return getProfileInstr() == ProfileClangInstr;
- }
-
- /// Check if IR level profile instrumentation is on.
- bool hasProfileIRInstr() const {
- return getProfileInstr() == ProfileIRInstr;
- }
-
- /// Check if Clang profile use is on.
- bool hasProfileClangUse() const {
- return getProfileUse() == ProfileClangInstr;
- }
-
- /// Check if IR level profile use is on.
- bool hasProfileIRUse() const {
- return getProfileUse() == ProfileIRInstr;
- }
-
-};
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 818c733982d9..83ce079d5e23 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -22,6 +22,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/BuryPointer.h"
#include <cassert>
#include <list>
#include <memory>
@@ -83,7 +84,7 @@ class CompilerInstance : public ModuleLoader {
IntrusiveRefCntPtr<TargetInfo> AuxTarget;
/// The virtual file system.
- IntrusiveRefCntPtr<vfs::FileSystem> VirtualFileSystem;
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VirtualFileSystem;
/// The file manager.
IntrusiveRefCntPtr<FileManager> FileMgr;
@@ -384,7 +385,7 @@ public:
bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; }
- vfs::FileSystem &getVirtualFileSystem() const {
+ llvm::vfs::FileSystem &getVirtualFileSystem() const {
assert(hasVirtualFileSystem() &&
"Compiler instance has no virtual file system");
return *VirtualFileSystem;
@@ -394,7 +395,7 @@ public:
///
/// \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) {
+ void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
VirtualFileSystem = std::move(FS);
}
@@ -411,7 +412,7 @@ public:
}
void resetAndLeakFileManager() {
- BuryPointer(FileMgr.get());
+ llvm::BuryPointer(FileMgr.get());
FileMgr.resetWithoutRelease();
}
@@ -431,7 +432,7 @@ public:
}
void resetAndLeakSourceManager() {
- BuryPointer(SourceMgr.get());
+ llvm::BuryPointer(SourceMgr.get());
SourceMgr.resetWithoutRelease();
}
@@ -453,7 +454,7 @@ public:
std::shared_ptr<Preprocessor> getPreprocessorPtr() { return PP; }
void resetAndLeakPreprocessor() {
- BuryPointer(new std::shared_ptr<Preprocessor>(PP));
+ llvm::BuryPointer(new std::shared_ptr<Preprocessor>(PP));
}
/// Replace the current preprocessor.
@@ -471,7 +472,7 @@ public:
}
void resetAndLeakASTContext() {
- BuryPointer(Context.get());
+ llvm::BuryPointer(Context.get());
Context.resetWithoutRelease();
}
diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h
index 1d421f09fdcc..a1874655b040 100644
--- a/include/clang/Frontend/CompilerInvocation.h
+++ b/include/clang/Frontend/CompilerInvocation.h
@@ -10,11 +10,11 @@
#ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H
#define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H
+#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
-#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/LangStandard.h"
@@ -35,6 +35,12 @@ class ArgList;
} // namespace opt
+namespace vfs {
+
+class FileSystem;
+
+} // namespace vfs
+
} // namespace llvm
namespace clang {
@@ -217,20 +223,13 @@ public:
/// @}
};
-namespace vfs {
-
-class FileSystem;
-
-} // namespace vfs
-
-IntrusiveRefCntPtr<vfs::FileSystem>
+IntrusiveRefCntPtr<llvm::vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags);
-IntrusiveRefCntPtr<vfs::FileSystem>
-createVFSFromCompilerInvocation(const CompilerInvocation &CI,
- DiagnosticsEngine &Diags,
- IntrusiveRefCntPtr<vfs::FileSystem> BaseFS);
+IntrusiveRefCntPtr<llvm::vfs::FileSystem> createVFSFromCompilerInvocation(
+ const CompilerInvocation &CI, DiagnosticsEngine &Diags,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
} // namespace clang
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h
index 2a4077d34391..22314386e060 100644
--- a/include/clang/Frontend/FrontendAction.h
+++ b/include/clang/Frontend/FrontendAction.h
@@ -48,6 +48,12 @@ protected:
/// @name Implementation Action Interface
/// @{
+ /// Prepare to execute the action on the given CompilerInstance.
+ ///
+ /// This is called before executing the action on any inputs, and can modify
+ /// the configuration as needed (including adjusting the input list).
+ virtual bool PrepareToExecuteAction(CompilerInstance &CI) { return true; }
+
/// Create the AST consumer object for this action, if supported.
///
/// This routine is called as part of BeginSourceFile(), which will
@@ -130,11 +136,18 @@ public:
return CurrentInput;
}
- const StringRef getCurrentFile() const {
+ StringRef getCurrentFile() const {
assert(!CurrentInput.isEmpty() && "No current file!");
return CurrentInput.getFile();
}
+ StringRef getCurrentFileOrBufferName() const {
+ assert(!CurrentInput.isEmpty() && "No current file!");
+ return CurrentInput.isFile()
+ ? CurrentInput.getFile()
+ : CurrentInput.getBuffer()->getBufferIdentifier();
+ }
+
InputKind getCurrentFileKind() const {
assert(!CurrentInput.isEmpty() && "No current file!");
return CurrentInput.getKind();
@@ -190,6 +203,11 @@ public:
/// @name Public Action Interface
/// @{
+ /// Prepare the action to execute on the given compiler instance.
+ bool PrepareToExecute(CompilerInstance &CI) {
+ return PrepareToExecuteAction(CI);
+ }
+
/// Prepare the action for processing the input file \p Input.
///
/// This is run after the options and frontend have been initialized,
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index 54539a5b3cee..eb1cd688429d 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -142,6 +142,19 @@ private:
CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
};
+class GenerateHeaderModuleAction : public GenerateModuleAction {
+ /// The synthesized module input buffer for the current compilation.
+ std::unique_ptr<llvm::MemoryBuffer> Buffer;
+ std::vector<std::string> ModuleHeaders;
+
+private:
+ bool PrepareToExecuteAction(CompilerInstance &CI) override;
+ bool BeginSourceFileAction(CompilerInstance &CI) override;
+
+ std::unique_ptr<raw_pwrite_stream>
+ CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
+};
+
class SyntaxOnlyAction : public ASTFrontendAction {
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
@@ -248,11 +261,6 @@ protected:
void ExecuteAction() override;
};
-class GeneratePTHAction : public PreprocessorFrontendAction {
-protected:
- void ExecuteAction() override;
-};
-
class PreprocessOnlyAction : public PreprocessorFrontendAction {
protected:
void ExecuteAction() override;
diff --git a/include/clang/Frontend/FrontendDiagnostic.h b/include/clang/Frontend/FrontendDiagnostic.h
index 0f37b7ece7e0..14a28845d45a 100644
--- a/include/clang/Frontend/FrontendDiagnostic.h
+++ b/include/clang/Frontend/FrontendDiagnostic.h
@@ -10,19 +10,6 @@
#ifndef LLVM_CLANG_FRONTEND_FRONTENDDIAGNOSTIC_H
#define LLVM_CLANG_FRONTEND_FRONTENDDIAGNOSTIC_H
-#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
- namespace diag {
- enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
-#define FRONTENDSTART
-#include "clang/Basic/DiagnosticFrontendKinds.inc"
-#undef DIAG
- NUM_BUILTIN_FRONTEND_DIAGNOSTICS
- };
- } // end namespace diag
-} // end namespace clang
+#include "clang/Basic/DiagnosticFrontend.h"
#endif
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 668df83274eb..92191ebd12a6 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -82,12 +82,12 @@ enum ActionKind {
/// Generate pre-compiled module from a C++ module interface file.
GenerateModuleInterface,
+ /// Generate pre-compiled module from a set of header files.
+ GenerateHeaderModule,
+
/// Generate pre-compiled header.
GeneratePCH,
- /// Generate pre-tokenized header.
- GeneratePTH,
-
/// Only execute frontend initialization.
InitOnly,
@@ -103,9 +103,6 @@ enum ActionKind {
/// Run a plugin action, \see ActionName.
PluginAction,
- /// Print DeclContext and their Decls.
- PrintDeclContext,
-
/// Print the "preamble" of the input file
PrintPreamble,
diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Frontend/LangStandards.def
index 1e895d785d15..0fdd35f32034 100644
--- a/include/clang/Frontend/LangStandards.def
+++ b/include/clang/Frontend/LangStandards.def
@@ -82,9 +82,12 @@ LANGSTANDARD(c17, "c17",
C, "ISO C 2017",
LineComment | C99 | C11 | C17 | Digraphs | HexFloat)
LANGSTANDARD_ALIAS(c17, "iso9899:2017")
+LANGSTANDARD_ALIAS(c17, "c18")
+LANGSTANDARD_ALIAS(c17, "iso9899:2018")
LANGSTANDARD(gnu17, "gnu17",
C, "ISO C 2017 with GNU extensions",
LineComment | C99 | C11 | C17 | Digraphs | GNUMode | HexFloat)
+LANGSTANDARD_ALIAS(gnu17, "gnu18")
// C++ modes
LANGSTANDARD(cxx98, "c++98",
diff --git a/include/clang/Frontend/PCHContainerOperations.h b/include/clang/Frontend/PCHContainerOperations.h
index 7a12ebc862e7..675efbaf56eb 100644
--- a/include/clang/Frontend/PCHContainerOperations.h
+++ b/include/clang/Frontend/PCHContainerOperations.h
@@ -10,110 +10,6 @@
#ifndef LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
#define LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
-#include "clang/Basic/Module.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include <memory>
-
-namespace llvm {
-class raw_pwrite_stream;
-}
-
-using llvm::StringRef;
-
-namespace clang {
-
-class ASTConsumer;
-class CodeGenOptions;
-class DiagnosticsEngine;
-class CompilerInstance;
-
-struct PCHBuffer {
- ASTFileSignature Signature;
- llvm::SmallVector<char, 0> Data;
- bool IsComplete;
-};
-
-/// This abstract interface provides operations for creating
-/// containers for serialized ASTs (precompiled headers and clang
-/// modules).
-class PCHContainerWriter {
-public:
- virtual ~PCHContainerWriter() = 0;
- virtual StringRef getFormat() const = 0;
-
- /// Return an ASTConsumer that can be chained with a
- /// PCHGenerator that produces a wrapper file format containing a
- /// serialized AST bitstream.
- virtual std::unique_ptr<ASTConsumer>
- CreatePCHContainerGenerator(CompilerInstance &CI,
- const std::string &MainFileName,
- const std::string &OutputFileName,
- std::unique_ptr<llvm::raw_pwrite_stream> OS,
- std::shared_ptr<PCHBuffer> Buffer) const = 0;
-};
-
-/// This abstract interface provides operations for unwrapping
-/// containers for serialized ASTs (precompiled headers and clang
-/// modules).
-class PCHContainerReader {
-public:
- virtual ~PCHContainerReader() = 0;
- /// Equivalent to the format passed to -fmodule-format=
- virtual StringRef getFormat() 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.
-class RawPCHContainerWriter : public PCHContainerWriter {
- StringRef getFormat() const override { return "raw"; }
-
- /// Return an ASTConsumer that can be chained with a
- /// PCHGenerator that writes the module to a flat file.
- std::unique_ptr<ASTConsumer>
- CreatePCHContainerGenerator(CompilerInstance &CI,
- const std::string &MainFileName,
- const std::string &OutputFileName,
- std::unique_ptr<llvm::raw_pwrite_stream> OS,
- std::shared_ptr<PCHBuffer> Buffer) const override;
-};
-
-/// Implements read operations for a raw pass-through PCH container.
-class RawPCHContainerReader : public PCHContainerReader {
- StringRef getFormat() const override { return "raw"; }
-
- /// Simply returns the buffer contained in Buffer.
- StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const override;
-};
-
-/// A registry of PCHContainerWriter and -Reader objects for different formats.
-class PCHContainerOperations {
- llvm::StringMap<std::unique_ptr<PCHContainerWriter>> Writers;
- llvm::StringMap<std::unique_ptr<PCHContainerReader>> Readers;
-public:
- /// Automatically registers a RawPCHContainerWriter and
- /// RawPCHContainerReader.
- PCHContainerOperations();
- void registerWriter(std::unique_ptr<PCHContainerWriter> Writer) {
- Writers[Writer->getFormat()] = std::move(Writer);
- }
- void registerReader(std::unique_ptr<PCHContainerReader> Reader) {
- Readers[Reader->getFormat()] = std::move(Reader);
- }
- const PCHContainerWriter *getWriterOrNull(StringRef Format) {
- return Writers[Format].get();
- }
- const PCHContainerReader *getReaderOrNull(StringRef Format) {
- return Readers[Format].get();
- }
- const PCHContainerReader &getRawReader() {
- return *getReaderOrNull("raw");
- }
-};
-
-}
+#include "clang/Serialization/PCHContainerOperations.h"
#endif
diff --git a/include/clang/Frontend/PrecompiledPreamble.h b/include/clang/Frontend/PrecompiledPreamble.h
index 6abdbe3a1e1b..6c79895ce1b9 100644
--- a/include/clang/Frontend/PrecompiledPreamble.h
+++ b/include/clang/Frontend/PrecompiledPreamble.h
@@ -26,13 +26,12 @@
namespace llvm {
class MemoryBuffer;
-}
-
-namespace clang {
namespace vfs {
class FileSystem;
}
+} // namespace llvm
+namespace clang {
class CompilerInstance;
class CompilerInvocation;
class DeclGroupRef;
@@ -80,7 +79,8 @@ public:
static llvm::ErrorOr<PrecompiledPreamble>
Build(const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
- DiagnosticsEngine &Diagnostics, IntrusiveRefCntPtr<vfs::FileSystem> VFS,
+ DiagnosticsEngine &Diagnostics,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
bool StoreInMemory, PreambleCallbacks &Callbacks);
@@ -99,7 +99,7 @@ public:
/// MainFileBuffer) of the main file.
bool CanReuse(const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
- vfs::FileSystem *VFS) const;
+ llvm::vfs::FileSystem *VFS) const;
/// Changes options inside \p CI to use PCH from this preamble. Also remaps
/// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble
@@ -110,14 +110,14 @@ public:
/// responsible for making sure the PrecompiledPreamble instance outlives the
/// compiler run and the AST that will be using the PCH.
void AddImplicitPreamble(CompilerInvocation &CI,
- IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;
/// Configure \p CI to use this preamble.
/// Like AddImplicitPreamble, but doesn't assume CanReuse() is true.
/// If this preamble does not match the file, it may parse differently.
void OverridePreamble(CompilerInvocation &CI,
- IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;
private:
@@ -233,15 +233,16 @@ private:
/// Helper function to set up PCH for the preamble into \p CI and \p VFS to
/// with the specified \p Bounds.
void configurePreamble(PreambleBounds Bounds, CompilerInvocation &CI,
- IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;
/// Sets up the PreprocessorOptions and changes VFS, so that PCH stored in \p
/// Storage is accessible to clang. This method is an implementation detail of
/// AddImplicitPreamble.
- static void setupPreambleStorage(const PCHStorage &Storage,
- PreprocessorOptions &PreprocessorOpts,
- IntrusiveRefCntPtr<vfs::FileSystem> &VFS);
+ static void
+ setupPreambleStorage(const PCHStorage &Storage,
+ PreprocessorOptions &PreprocessorOpts,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS);
/// Manages the memory buffer or temporary file that stores the PCH.
PCHStorage Storage;
@@ -286,8 +287,7 @@ public:
};
enum class BuildPreambleError {
- PreambleIsEmpty = 1,
- CouldntCreateTempFile,
+ CouldntCreateTempFile = 1,
CouldntCreateTargetInfo,
BeginSourceFileFailed,
CouldntEmitPCH
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 67912a8dfcdd..89a6b90f293f 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -16,13 +16,13 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
-#include "clang/Basic/VirtualFileSystem.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Option/OptSpecifier.h"
+#include "llvm/Support/VirtualFileSystem.h"
#include <cstdint>
#include <memory>
#include <string>
@@ -134,7 +134,7 @@ class ModuleDependencyCollector : public DependencyCollector {
std::string DestDir;
bool HasErrors = false;
llvm::StringSet<> Seen;
- vfs::YAMLVFSWriter VFSWriter;
+ llvm::vfs::YAMLVFSWriter VFSWriter;
llvm::StringMap<std::string> SymLinkMap;
bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result);
@@ -183,9 +183,6 @@ void AttachHeaderIncludeGen(Preprocessor &PP,
StringRef OutputPath = {},
bool ShowDepth = true, bool MSStyle = false);
-/// Cache tokens for use with PCH. Note that this requires a seekable stream.
-void CacheTokens(Preprocessor &PP, raw_pwrite_stream *OS);
-
/// The ChainedIncludesSource class converts headers to chained PCHs in
/// memory, mainly for testing.
IntrusiveRefCntPtr<ExternalSemaSource>
@@ -201,7 +198,7 @@ std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(
ArrayRef<const char *> Args,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
IntrusiveRefCntPtr<DiagnosticsEngine>(),
- IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// 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.
@@ -226,14 +223,6 @@ inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
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);
-template <typename T> void BuryPointer(std::unique_ptr<T> Ptr) {
- BuryPointer(Ptr.release());
-}
-
// Frontend timing utils
/// If the user specifies the -ftime-report argument on an Clang command line