aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:06:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:06:01 +0000
commit486754660bb926339aefcf012a3f848592babb8b (patch)
treeecdbc446c9876f4f120f701c243373cd3cb43db3 /include/clang/Frontend
parent55e6d896ad333f07bb3b1ba487df214fc268a4ab (diff)
downloadsrc-vendor/clang/clang-trunk-r338150.tar.gz
src-vendor/clang/clang-trunk-r338150.zip
Vendor import of clang trunk r338150:vendor/clang/clang-trunk-r338150
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h7
-rw-r--r--include/clang/Frontend/ASTUnit.h286
-rw-r--r--include/clang/Frontend/ChainedDiagnosticConsumer.h2
-rw-r--r--include/clang/Frontend/CodeGenOptions.def54
-rw-r--r--include/clang/Frontend/CodeGenOptions.h34
-rw-r--r--include/clang/Frontend/CommandLineSourceLoc.h4
-rw-r--r--include/clang/Frontend/CompilerInstance.h53
-rw-r--r--include/clang/Frontend/CompilerInvocation.h78
-rw-r--r--include/clang/Frontend/DependencyOutputOptions.h25
-rw-r--r--include/clang/Frontend/DiagnosticRenderer.h32
-rw-r--r--include/clang/Frontend/FrontendAction.h48
-rw-r--r--include/clang/Frontend/FrontendActions.h32
-rw-r--r--include/clang/Frontend/FrontendOptions.h357
-rw-r--r--include/clang/Frontend/FrontendPluginRegistry.h12
-rw-r--r--include/clang/Frontend/LangStandards.def7
-rw-r--r--include/clang/Frontend/LayoutOverrideSource.h20
-rw-r--r--include/clang/Frontend/MultiplexConsumer.h23
-rw-r--r--include/clang/Frontend/PrecompiledPreamble.h27
-rw-r--r--include/clang/Frontend/SerializedDiagnosticPrinter.h6
-rw-r--r--include/clang/Frontend/SerializedDiagnosticReader.h83
-rw-r--r--include/clang/Frontend/SerializedDiagnostics.h8
-rw-r--r--include/clang/Frontend/TextDiagnostic.h6
-rw-r--r--include/clang/Frontend/TextDiagnosticBuffer.h32
-rw-r--r--include/clang/Frontend/TextDiagnosticPrinter.h2
-rw-r--r--include/clang/Frontend/Utils.h73
-rw-r--r--include/clang/Frontend/VerifyDiagnosticConsumer.h62
26 files changed, 838 insertions, 535 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index 53975a07ea94..2a13527df135 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -34,9 +34,10 @@ class TargetOptions;
std::unique_ptr<ASTConsumer> CreateASTPrinter(std::unique_ptr<raw_ostream> OS,
StringRef FilterString);
-// AST dumper: dumps the raw AST in human-readable form to stderr; this is
-// intended for debugging.
-std::unique_ptr<ASTConsumer> CreateASTDumper(StringRef FilterString,
+// AST dumper: dumps the raw AST in human-readable form to the given output
+// stream, or stdout if OS is nullptr.
+std::unique_ptr<ASTConsumer> CreateASTDumper(std::unique_ptr<raw_ostream> OS,
+ StringRef FilterString,
bool DumpDecls, bool Deserialize,
bool DumpLookups);
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index 5d04dcd19119..9f529ba0e0e8 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -1,4 +1,4 @@
-//===--- ASTUnit.h - ASTUnit utility ----------------------------*- C++ -*-===//
+//===- ASTUnit.h - ASTUnit utility ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,8 +16,11 @@
#include "clang-c/Index.h"
#include "clang/AST/ASTContext.h"
+#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Lex/HeaderSearchOptions.h"
@@ -26,48 +29,62 @@
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Frontend/PrecompiledPreamble.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/MD5.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
#include <cassert>
+#include <cstddef>
+#include <cstdint>
#include <memory>
#include <string>
-#include <sys/types.h>
#include <utility>
#include <vector>
namespace llvm {
- class MemoryBuffer;
-}
+
+class MemoryBuffer;
+
+} // namespace llvm
namespace clang {
-class Sema;
+
class ASTContext;
+class ASTDeserializationListener;
+class ASTMutationListener;
class ASTReader;
-class CompilerInvocation;
class CompilerInstance;
+class CompilerInvocation;
class Decl;
-class DiagnosticsEngine;
class FileEntry;
class FileManager;
+class FrontendAction;
class HeaderSearch;
class InputKind;
class MemoryBufferCache;
-class Preprocessor;
-class PreprocessorOptions;
class PCHContainerOperations;
class PCHContainerReader;
+class Preprocessor;
+class PreprocessorOptions;
+class Sema;
class TargetInfo;
-class FrontendAction;
-class ASTDeserializationListener;
namespace vfs {
+
class FileSystem;
-}
-/// \brief Utility class for loading a ASTContext from an AST file.
-///
+} // namespace vfs
+
+/// \brief Enumerates the available scopes for skipping function bodies.
+enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
+
+/// Utility class for loading a ASTContext from an AST file.
class ASTUnit {
public:
struct StandaloneFixIt {
@@ -83,7 +100,7 @@ public:
std::string Message;
std::string Filename;
unsigned LocOffset;
- std::vector<std::pair<unsigned, unsigned> > Ranges;
+ std::vector<std::pair<unsigned, unsigned>> Ranges;
std::vector<StandaloneFixIt> FixIts;
};
@@ -101,18 +118,18 @@ private:
std::shared_ptr<HeaderSearchOptions> HSOpts;
std::shared_ptr<PreprocessorOptions> PPOpts;
IntrusiveRefCntPtr<ASTReader> Reader;
- bool HadModuleLoaderFatalFailure;
+ bool HadModuleLoaderFatalFailure = false;
struct ASTWriterData;
std::unique_ptr<ASTWriterData> WriterData;
FileSystemOptions FileSystemOpts;
- /// \brief The AST consumer that received information about the translation
+ /// The AST consumer that received information about the translation
/// unit as it was parsed or loaded.
std::unique_ptr<ASTConsumer> Consumer;
- /// \brief The semantic analysis object used to type-check the translation
+ /// The semantic analysis object used to type-check the translation
/// unit.
std::unique_ptr<Sema> TheSema;
@@ -126,22 +143,22 @@ private:
// 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.
- bool OnlyLocalDecls;
+ bool OnlyLocalDecls = false;
- /// \brief Whether to capture any diagnostics produced.
- bool CaptureDiagnostics;
+ /// Whether to capture any diagnostics produced.
+ bool CaptureDiagnostics = false;
- /// \brief Track whether the main file was loaded from an AST or not.
+ /// Track whether the main file was loaded from an AST or not.
bool MainFileIsAST;
- /// \brief What kind of translation unit this AST represents.
- TranslationUnitKind TUKind;
+ /// What kind of translation unit this AST represents.
+ TranslationUnitKind TUKind = TU_Complete;
- /// \brief Whether we should time each operation.
+ /// Whether we should time each operation.
bool WantTiming;
- /// \brief Whether the ASTUnit should delete the remapped buffers.
- bool OwnsRemappedFileBuffers;
+ /// Whether the ASTUnit should delete the remapped buffers.
+ bool OwnsRemappedFileBuffers = true;
/// Track the top-level decls which appeared in an ASTUnit which was loaded
/// from a source file.
@@ -152,36 +169,36 @@ private:
// more scalable search mechanisms.
std::vector<Decl*> TopLevelDecls;
- /// \brief Sorted (by file offset) vector of pairs of file offset/Decl.
- typedef SmallVector<std::pair<unsigned, Decl *>, 64> LocDeclsTy;
- typedef llvm::DenseMap<FileID, LocDeclsTy *> FileDeclsTy;
+ /// Sorted (by file offset) vector of pairs of file offset/Decl.
+ using LocDeclsTy = SmallVector<std::pair<unsigned, Decl *>, 64>;
+ using FileDeclsTy = llvm::DenseMap<FileID, LocDeclsTy *>;
- /// \brief Map from FileID to the file-level declarations that it contains.
+ /// Map from FileID to the file-level declarations that it contains.
/// The files and decls are only local (and non-preamble) ones.
FileDeclsTy FileDecls;
/// The name of the original source file used to generate this ASTUnit.
std::string OriginalSourceFile;
- /// \brief The set of diagnostics produced when creating the preamble.
+ /// The set of diagnostics produced when creating the preamble.
SmallVector<StandaloneDiagnostic, 4> PreambleDiagnostics;
- /// \brief The set of diagnostics produced when creating this
+ /// The set of diagnostics produced when creating this
/// translation unit.
SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
- /// \brief The set of diagnostics produced when failing to parse, e.g. due
+ /// The set of diagnostics produced when failing to parse, e.g. due
/// to failure to load the PCH.
SmallVector<StoredDiagnostic, 4> FailedParseDiagnostics;
- /// \brief The number of stored diagnostics that come from the driver
+ /// 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;
+ unsigned NumStoredDiagnosticsFromDriver = 0;
- /// \brief Counter that determines when we want to try building a
+ /// Counter that determines when we want to try building a
/// precompiled preamble.
///
/// If zero, we will never build a precompiled preamble. Otherwise,
@@ -190,45 +207,44 @@ private:
/// we'll attempt to rebuild the precompiled header. This way, if
/// building the precompiled preamble fails, we won't try again for
/// some number of calls.
- unsigned PreambleRebuildCounter;
+ unsigned PreambleRebuildCounter = 0;
- /// \brief Cache pairs "filename - source location"
+ /// Cache pairs "filename - source location"
///
/// Cache contains only source locations from preamble so it is
/// guaranteed that they stay valid when the SourceManager is recreated.
- /// This cache is used when loading preambule to increase performance
+ /// This cache is used when loading preamble to increase performance
/// of that loading. It must be cleared when preamble is recreated.
llvm::StringMap<SourceLocation> PreambleSrcLocCache;
-private:
/// The contents of the preamble.
llvm::Optional<PrecompiledPreamble> Preamble;
- /// \brief When non-NULL, this is the buffer used to store the contents of
+ /// When non-NULL, this is the buffer used to store the contents of
/// the main file when it has been padded for use with the precompiled
/// preamble.
std::unique_ptr<llvm::MemoryBuffer> SavedMainFileBuffer;
- /// \brief The number of warnings that occurred while parsing the preamble.
+ /// The number of warnings that occurred while parsing the preamble.
///
/// This value will be used to restore the state of the \c DiagnosticsEngine
/// object when re-using the precompiled preamble. Note that only the
/// number of warnings matters, since we will not save the preamble
/// when any errors are present.
- unsigned NumWarningsInPreamble;
+ unsigned NumWarningsInPreamble = 0;
- /// \brief A list of the serialization ID numbers for each of the top-level
+ /// A list of the serialization ID numbers for each of the top-level
/// declarations parsed within the precompiled preamble.
std::vector<serialization::DeclID> TopLevelDeclsInPreamble;
- /// \brief Whether we should be caching code-completion results.
+ /// Whether we should be caching code-completion results.
bool ShouldCacheCodeCompletionResults : 1;
- /// \brief Whether to include brief documentation within the set of code
+ /// Whether to include brief documentation within the set of code
/// completions cached.
bool IncludeBriefCommentsInCodeCompletion : 1;
- /// \brief True if non-system source files should be treated as volatile
+ /// True if non-system source files should be treated as volatile
/// (likely to change while trying to use them).
bool UserFilesAreVolatile : 1;
@@ -243,14 +259,14 @@ private:
void clearFileLevelDecls();
public:
- /// \brief A cached code-completion result, which may be introduced in one of
+ /// A cached code-completion result, which may be introduced in one of
/// many different contexts.
struct CachedCodeCompletionResult {
- /// \brief The code-completion string corresponding to this completion
+ /// The code-completion string corresponding to this completion
/// result.
CodeCompletionString *Completion;
- /// \brief A bitmask that indicates which code-completion contexts should
+ /// A bitmask that indicates which code-completion contexts should
/// contain this completion result.
///
/// The bits in the bitmask correspond to the values of
@@ -259,20 +275,20 @@ public:
/// several different contexts.
uint64_t ShowInContexts;
- /// \brief The priority given to this code-completion result.
+ /// The priority given to this code-completion result.
unsigned Priority;
- /// \brief The libclang cursor kind corresponding to this code-completion
+ /// The libclang cursor kind corresponding to this code-completion
/// result.
CXCursorKind Kind;
- /// \brief The availability of this code-completion result.
+ /// The availability of this code-completion result.
CXAvailabilityKind Availability;
- /// \brief The simplified type class for a non-macro completion result.
+ /// The simplified type class for a non-macro completion result.
SimplifiedTypeClass TypeClass;
- /// \brief The type of a non-macro completion result, stored as a unique
+ /// The type of a non-macro completion result, stored as a unique
/// integer used by the string map of cached completion types.
///
/// This value will be zero if the type is not known, or a unique value
@@ -281,13 +297,13 @@ public:
unsigned Type;
};
- /// \brief Retrieve the mapping from formatted type names to unique type
+ /// Retrieve the mapping from formatted type names to unique type
/// identifiers.
- llvm::StringMap<unsigned> &getCachedCompletionTypes() {
+ llvm::StringMap<unsigned> &getCachedCompletionTypes() {
return CachedCompletionTypes;
}
- /// \brief Retrieve the allocator used to cache global code completions.
+ /// Retrieve the allocator used to cache global code completions.
std::shared_ptr<GlobalCodeCompletionAllocator>
getCachedCompletionAllocator() {
return CachedCompletionAllocator;
@@ -301,50 +317,50 @@ public:
}
private:
- /// \brief Allocator used to store cached code completions.
+ /// Allocator used to store cached code completions.
std::shared_ptr<GlobalCodeCompletionAllocator> CachedCompletionAllocator;
std::unique_ptr<CodeCompletionTUInfo> CCTUInfo;
- /// \brief The set of cached code-completion results.
+ /// The set of cached code-completion results.
std::vector<CachedCodeCompletionResult> CachedCompletionResults;
- /// \brief A mapping from the formatted type name to a unique number for that
+ /// A mapping from the formatted type name to a unique number for that
/// type, which is used for type equality comparisons.
llvm::StringMap<unsigned> CachedCompletionTypes;
- /// \brief A string hash of the top-level declaration and macro definition
+ /// A string hash of the top-level declaration and macro definition
/// names processed the last time that we reparsed the file.
///
/// This hash value is used to determine when we need to refresh the
/// global code-completion cache.
- unsigned CompletionCacheTopLevelHashValue;
+ unsigned CompletionCacheTopLevelHashValue = 0;
- /// \brief A string hash of the top-level declaration and macro definition
+ /// A string hash of the top-level declaration and macro definition
/// names processed the last time that we reparsed the precompiled preamble.
///
/// 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;
+ unsigned PreambleTopLevelHashValue = 0;
- /// \brief The current hash value for the top-level declaration and macro
+ /// The current hash value for the top-level declaration and macro
/// definition names
- unsigned CurrentTopLevelHashValue;
+ unsigned CurrentTopLevelHashValue = 0;
- /// \brief Bit used by CIndex to mark when a translation unit may be in an
+ /// 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;
- /// \brief Cache any "global" code-completion results, so that we can avoid
+ /// \brief Enumerator specifying the scope for skipping function bodies.
+ SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None;
+
+ /// Cache any "global" code-completion results, so that we can avoid
/// recomputing them with each completion.
void CacheCodeCompletionResults();
- /// \brief Clear out and deallocate
+ /// Clear out and deallocate
void ClearCachedCompletionResults();
- ASTUnit(const ASTUnit &) = delete;
- void operator=(const ASTUnit &) = delete;
-
explicit ASTUnit(bool MainFileIsAST);
bool Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
@@ -353,16 +369,16 @@ private:
std::unique_ptr<llvm::MemoryBuffer> getMainBufferWithPrecompiledPreamble(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- const CompilerInvocation &PreambleInvocationIn,
+ CompilerInvocation &PreambleInvocationIn,
IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild = true,
unsigned MaxLines = 0);
void RealizeTopLevelDeclsFromPreamble();
- /// \brief Transfers ownership of the objects (like SourceManager) from
+ /// Transfers ownership of the objects (like SourceManager) from
/// \param CI to this ASTUnit.
void transferASTDataFromCompilerInstance(CompilerInstance &CI);
- /// \brief Allows us to assert that ASTUnit is not being used concurrently,
+ /// Allows us to assert that ASTUnit is not being used concurrently,
/// which is not supported.
///
/// Clients should create instances of the ConcurrencyCheck class whenever
@@ -382,21 +398,23 @@ private:
ConcurrencyState ConcurrencyCheckValue;
public:
+ friend class ConcurrencyCheck;
+
class ConcurrencyCheck {
ASTUnit &Self;
public:
- explicit ConcurrencyCheck(ASTUnit &Self)
- : Self(Self)
- {
+ explicit ConcurrencyCheck(ASTUnit &Self) : Self(Self) {
Self.ConcurrencyCheckValue.start();
}
+
~ConcurrencyCheck() {
Self.ConcurrencyCheckValue.finish();
}
};
- friend class ConcurrencyCheck;
+ ASTUnit(const ASTUnit &) = delete;
+ ASTUnit &operator=(const ASTUnit &) = delete;
~ASTUnit();
bool isMainFileAST() const { return MainFileIsAST; }
@@ -405,22 +423,32 @@ public:
void setUnsafeToFree(bool Value) { UnsafeToFree = Value; }
const DiagnosticsEngine &getDiagnostics() const { return *Diagnostics; }
- DiagnosticsEngine &getDiagnostics() { return *Diagnostics; }
+ DiagnosticsEngine &getDiagnostics() { return *Diagnostics; }
const SourceManager &getSourceManager() const { return *SourceMgr; }
- SourceManager &getSourceManager() { return *SourceMgr; }
+ SourceManager &getSourceManager() { return *SourceMgr; }
const Preprocessor &getPreprocessor() const { return *PP; }
- Preprocessor &getPreprocessor() { return *PP; }
+ Preprocessor &getPreprocessor() { return *PP; }
std::shared_ptr<Preprocessor> getPreprocessorPtr() const { return PP; }
const ASTContext &getASTContext() const { return *Ctx; }
- ASTContext &getASTContext() { return *Ctx; }
+ ASTContext &getASTContext() { return *Ctx; }
void setASTContext(ASTContext *ctx) { Ctx = ctx; }
void setPreprocessor(std::shared_ptr<Preprocessor> pp);
+ /// Enable source-range based diagnostic messages.
+ ///
+ /// If diagnostic messages with source-range information are to be expected
+ /// and AST comes not from file (e.g. after LoadFromCompilerInvocation) this
+ /// function has to be called.
+ /// The function is to be called only once and the AST should be associated
+ /// with the same source file afterwards.
+ void enableSourceFileDiagnostics();
+
bool hasSema() const { return (bool)TheSema; }
+
Sema &getSema() const {
assert(TheSema && "ASTUnit does not have a Sema object!");
return *TheSema;
@@ -442,7 +470,7 @@ public:
}
const FileManager &getFileManager() const { return *FileMgr; }
- FileManager &getFileManager() { return *FileMgr; }
+ FileManager &getFileManager() { return *FileMgr; }
const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
@@ -462,10 +490,10 @@ public:
StringRef getMainFileName() const;
- /// \brief If this ASTUnit came from an AST file, returns the filename for it.
+ /// If this ASTUnit came from an AST file, returns the filename for it.
StringRef getASTFileName() const;
- typedef std::vector<Decl *>::iterator top_level_iterator;
+ using top_level_iterator = std::vector<Decl *>::iterator;
top_level_iterator top_level_begin() {
assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
@@ -491,26 +519,26 @@ public:
return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty();
}
- /// \brief Add a new top-level declaration.
+ /// Add a new top-level declaration.
void addTopLevelDecl(Decl *D) {
TopLevelDecls.push_back(D);
}
- /// \brief Add a new local file-level declaration.
+ /// Add a new local file-level declaration.
void addFileLevelDecl(Decl *D);
- /// \brief Get the decls that are contained in a file in the Offset/Length
+ /// Get the decls that are contained in a file in the Offset/Length
/// range. \p Length can be 0 to indicate a point at \p Offset instead of
/// a range.
void findFileRegionDecls(FileID File, unsigned Offset, unsigned Length,
SmallVectorImpl<Decl *> &Decls);
- /// \brief Retrieve a reference to the current top-level name hash value.
+ /// 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; }
- /// \brief Get the source location for the given file:line:col triplet.
+ /// Get the source location for the given file:line:col triplet.
///
/// The difference with SourceManager::getLocation is that this method checks
/// whether the requested location points inside the precompiled preamble
@@ -518,15 +546,15 @@ public:
SourceLocation getLocation(const FileEntry *File,
unsigned Line, unsigned Col) const;
- /// \brief Get the source location for the given file:offset pair.
+ /// Get the source location for the given file:offset pair.
SourceLocation getLocation(const FileEntry *File, unsigned Offset) const;
- /// \brief If \p Loc is a loaded location from the preamble, returns
+ /// If \p Loc is a loaded location from the preamble, returns
/// the corresponding local location of the main file, otherwise it returns
/// \p Loc.
SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
- /// \brief If \p Loc is a local location of the main file but inside the
+ /// If \p Loc is a local location of the main file but inside the
/// preamble chunk, returns the corresponding loaded location from the
/// preamble, otherwise it returns \p Loc.
SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
@@ -549,20 +577,25 @@ public:
}
// Retrieve the diagnostics associated with this AST
- typedef StoredDiagnostic *stored_diag_iterator;
- typedef const StoredDiagnostic *stored_diag_const_iterator;
+ using stored_diag_iterator = StoredDiagnostic *;
+ using stored_diag_const_iterator = const StoredDiagnostic *;
+
stored_diag_const_iterator stored_diag_begin() const {
return StoredDiagnostics.begin();
}
+
stored_diag_iterator stored_diag_begin() {
return StoredDiagnostics.begin();
}
+
stored_diag_const_iterator stored_diag_end() const {
return StoredDiagnostics.end();
}
+
stored_diag_iterator stored_diag_end() {
return StoredDiagnostics.end();
}
+
unsigned stored_diag_size() const { return StoredDiagnostics.size(); }
stored_diag_iterator stored_diag_afterDriver_begin() {
@@ -571,8 +604,8 @@ public:
return StoredDiagnostics.begin() + NumStoredDiagnosticsFromDriver;
}
- typedef std::vector<CachedCodeCompletionResult>::iterator
- cached_completion_iterator;
+ using cached_completion_iterator =
+ std::vector<CachedCodeCompletionResult>::iterator;
cached_completion_iterator cached_completion_begin() {
return CachedCompletionResults.begin();
@@ -586,43 +619,43 @@ public:
return CachedCompletionResults.size();
}
- /// \brief Returns an iterator range for the local preprocessing entities
+ /// Returns an iterator range for the local preprocessing entities
/// of the local Preprocessor, if this is a parsed source file, or the loaded
/// preprocessing entities of the primary module if this is an AST file.
llvm::iterator_range<PreprocessingRecord::iterator>
getLocalPreprocessingEntities() const;
- /// \brief Type for a function iterating over a number of declarations.
+ /// Type for a function iterating over a number of declarations.
/// \returns true to continue iteration and false to abort.
- typedef bool (*DeclVisitorFn)(void *context, const Decl *D);
+ using DeclVisitorFn = bool (*)(void *context, const Decl *D);
- /// \brief Iterate over local declarations (locally parsed if this is a parsed
+ /// Iterate over local declarations (locally parsed if this is a parsed
/// source file or the loaded declarations of the primary module if this is an
/// AST file).
/// \returns true if the iteration was complete or false if it was aborted.
bool visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn);
- /// \brief Get the PCH file if one was included.
+ /// Get the PCH file if one was included.
const FileEntry *getPCHFile();
- /// \brief Returns true if the ASTUnit was constructed from a serialized
+ /// Returns true if the ASTUnit was constructed from a serialized
/// module file.
bool isModuleFile() const;
std::unique_ptr<llvm::MemoryBuffer>
getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);
- /// \brief Determine what kind of translation unit this AST represents.
+ /// Determine what kind of translation unit this AST represents.
TranslationUnitKind getTranslationUnitKind() const { return TUKind; }
- /// \brief Determine the input kind this AST unit represents.
+ /// Determine the input kind this AST unit represents.
InputKind getInputKind() const;
- /// \brief A mapping from a file name to the memory buffer that stores the
+ /// A mapping from a file name to the memory buffer that stores the
/// remapped contents of that file.
- typedef std::pair<std::string, llvm::MemoryBuffer *> RemappedFile;
+ using RemappedFile = std::pair<std::string, llvm::MemoryBuffer *>;
- /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
+ /// 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,
@@ -631,13 +664,15 @@ public:
enum WhatToLoad {
/// Load options and the preprocessor state.
LoadPreprocessorOnly,
+
/// Load the AST, but do not restore Sema state.
LoadASTOnly,
+
/// Load everything, including Sema.
LoadEverything
};
- /// \brief Create a ASTUnit from an AST file.
+ /// Create a ASTUnit from an AST file.
///
/// \param Filename - The AST file to load.
///
@@ -656,7 +691,7 @@ public:
bool UserFilesAreVolatile = false);
private:
- /// \brief Helper function for \c LoadFromCompilerInvocation() and
+ /// Helper function for \c LoadFromCompilerInvocation() and
/// \c LoadFromCommandLine(), which loads an AST from a compiler invocation.
///
/// \param PrecompilePreambleAfterNParses After how many parses the preamble
@@ -676,8 +711,7 @@ private:
IntrusiveRefCntPtr<vfs::FileSystem> VFS);
public:
-
- /// \brief Create an ASTUnit from a source file, via a CompilerInvocation
+ /// Create an ASTUnit from a source file, via a CompilerInvocation
/// object, by invoking the optionally provided ASTFrontendAction.
///
/// \param CI - The compiler invocation to use; it must have exactly one input
@@ -782,14 +816,16 @@ public:
TranslationUnitKind TUKind = TU_Complete,
bool CacheCodeCompletionResults = false,
bool IncludeBriefCommentsInCodeCompletion = false,
- bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false,
- bool SingleFileParse = false,
- bool UserFilesAreVolatile = false, bool ForSerialization = false,
+ bool AllowPCHWithCompilerErrors = false,
+ SkipFunctionBodiesScope SkipFunctionBodies =
+ SkipFunctionBodiesScope::None,
+ bool SingleFileParse = false, bool UserFilesAreVolatile = false,
+ bool ForSerialization = false,
llvm::Optional<StringRef> ModuleFormat = llvm::None,
std::unique_ptr<ASTUnit> *ErrAST = nullptr,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
- /// \brief Reparse the source files using the same command-line options that
+ /// 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
@@ -804,12 +840,12 @@ public:
ArrayRef<RemappedFile> RemappedFiles = None,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
- /// \brief Free data that will be re-generated on the next parse.
+ /// Free data that will be re-generated on the next parse.
///
/// Preamble-related data is not affected.
void ResetForParse();
- /// \brief Perform code completion at the given file, line, and
+ /// Perform code completion at the given file, line, and
/// column within this translation unit.
///
/// \param File The file in which code completion will occur.
@@ -839,13 +875,13 @@ public:
SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers);
- /// \brief Save this translation unit to a file with the given name.
+ /// Save this translation unit to a file with the given name.
///
/// \returns true if there was a file error or false if the save was
/// successful.
bool Save(StringRef File);
- /// \brief Serialize this translation unit with the given output stream.
+ /// Serialize this translation unit with the given output stream.
///
/// \returns True if an error occurred, false otherwise.
bool serialize(raw_ostream &OS);
@@ -853,4 +889,4 @@ public:
} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_ASTUNIT_H
diff --git a/include/clang/Frontend/ChainedDiagnosticConsumer.h b/include/clang/Frontend/ChainedDiagnosticConsumer.h
index eb33273c2fb3..04c6077dc35e 100644
--- a/include/clang/Frontend/ChainedDiagnosticConsumer.h
+++ b/include/clang/Frontend/ChainedDiagnosticConsumer.h
@@ -32,7 +32,7 @@ public:
: OwningPrimary(std::move(Primary)), Primary(OwningPrimary.get()),
Secondary(std::move(Secondary)) {}
- /// \brief Construct without taking ownership of \c Primary.
+ /// Construct without taking ownership of \c Primary.
ChainedDiagnosticConsumer(DiagnosticConsumer *Primary,
std::unique_ptr<DiagnosticConsumer> Secondary)
: Primary(Primary), Secondary(std::move(Secondary)) {}
diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def
index bb91cf5f742b..a7e71f7ac016 100644
--- a/include/clang/Frontend/CodeGenOptions.def
+++ b/include/clang/Frontend/CodeGenOptions.def
@@ -38,10 +38,12 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) o
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.
@@ -61,15 +63,19 @@ 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 when -femulated-tls is enabled.
-/// \brief Embed Bitcode mode (off/all/bitcode/marker).
+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.
@@ -80,13 +86,20 @@ 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)
@@ -97,7 +110,7 @@ CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions t
///< be generated.
CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
///< compile step.
-CODEGENOPT(EmitSummaryIndex, 1, 0) ///< Set when -flto=thin is enabled on the
+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).
@@ -117,27 +130,32 @@ 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.
-/// \brief Method of Objective-C dispatch to use.
+/// 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.
-/// A version of Clang that we should attempt to be ABI-compatible with.
-ENUM_CODEGENOPT(ClangABICompat, ClangABI, 4, ClangABI::Latest)
-
VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
-/// \brief Choose profile instrumenation kind or no instrumentation.
+/// Choose profile instrumenation kind or no instrumentation.
ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
-/// \brief Choose profile kind for PGO use compilation.
+/// 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.
@@ -154,6 +172,9 @@ CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-
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
@@ -218,6 +239,7 @@ 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.
@@ -230,7 +252,7 @@ CODEGENOPT(DebugExplicitImport, 1, 0) ///< Whether or not debug info should
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.
+ ///< of inline stack frames without .dwo files.
CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
///< template parameter descriptions in
///< forward declarations (versus just
@@ -308,6 +330,16 @@ 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
index 6b8d2b935fdd..a6d061acf0f4 100644
--- a/include/clang/Frontend/CodeGenOptions.h
+++ b/include/clang/Frontend/CodeGenOptions.h
@@ -16,6 +16,8 @@
#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>
@@ -25,7 +27,7 @@
namespace clang {
-/// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
+/// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
/// that this large collection of bitfields is a trivial class type.
class CodeGenOptionsBase {
public:
@@ -167,7 +169,7 @@ public:
std::string SplitDwarfFile;
/// The name of the relocation model to use.
- std::string RelocationModel;
+ llvm::Reloc::Model RelocationModel;
/// The thread model to use
std::string ThreadModel;
@@ -176,9 +178,6 @@ public:
/// function instead of to trap instructions.
std::string TrapFuncName;
- /// A list of command-line options to forward to the LLVM backend.
- std::vector<std::string> BackendOptions;
-
/// A list of dependent libraries.
std::vector<std::string> DependentLibraries;
@@ -204,10 +203,12 @@ public:
/// the summary and module symbol table (and not, e.g. any debug metadata).
std::string ThinLinkBitcodeFile;
- /// A list of file names passed with -fcuda-include-gpubinary options to
- /// forward to CUDA runtime back-end for incorporating them into host-side
- /// object file.
- std::vector<std::string> CudaGpuBinaryFileNames;
+ /// 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.
@@ -248,7 +249,7 @@ public:
/// List of backend command-line options for -fembed-bitcode.
std::vector<uint8_t> CmdArgs;
- /// \brief A list of all -fno-builtin-* function names (e.g., memset).
+ /// A list of all -fno-builtin-* function names (e.g., memset).
std::vector<std::string> NoBuiltinFuncs;
std::vector<std::string> Reciprocals;
@@ -258,6 +259,9 @@ public:
/// 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)
@@ -268,7 +272,7 @@ public:
CodeGenOptions();
- /// \brief Is this a libc/libm function that is no longer recognized as a
+ /// 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;
@@ -276,22 +280,22 @@ public:
return NoBuiltinFuncs;
}
- /// \brief Check if Clang profile instrumenation is on.
+ /// Check if Clang profile instrumenation is on.
bool hasProfileClangInstr() const {
return getProfileInstr() == ProfileClangInstr;
}
- /// \brief Check if IR level profile instrumentation is on.
+ /// Check if IR level profile instrumentation is on.
bool hasProfileIRInstr() const {
return getProfileInstr() == ProfileIRInstr;
}
- /// \brief Check if Clang profile use is on.
+ /// Check if Clang profile use is on.
bool hasProfileClangUse() const {
return getProfileUse() == ProfileClangInstr;
}
- /// \brief Check if IR level profile use is on.
+ /// Check if IR level profile use is on.
bool hasProfileIRUse() const {
return getProfileUse() == ProfileIRInstr;
}
diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h
index f5c1e1a8a67d..7ae98e079264 100644
--- a/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/include/clang/Frontend/CommandLineSourceLoc.h
@@ -21,7 +21,7 @@
namespace clang {
-/// \brief A source location that has been parsed on the command line.
+/// A source location that has been parsed on the command line.
struct ParsedSourceLocation {
std::string FileName;
unsigned Line;
@@ -101,7 +101,7 @@ struct ParsedSourceRange {
namespace llvm {
namespace cl {
- /// \brief Command-line option parser that parses source locations.
+ /// Command-line option parser that parses source locations.
///
/// Source locations are of the form filename:line:column.
template<>
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 90a9501475b5..977d1b2ed65f 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -109,59 +109,59 @@ class CompilerInstance : public ModuleLoader {
/// The code completion consumer.
std::unique_ptr<CodeCompleteConsumer> CompletionConsumer;
- /// \brief The semantic analysis object.
+ /// The semantic analysis object.
std::unique_ptr<Sema> TheSema;
- /// \brief The frontend timer group.
+ /// The frontend timer group.
std::unique_ptr<llvm::TimerGroup> FrontendTimerGroup;
- /// \brief The frontend timer.
+ /// The frontend timer.
std::unique_ptr<llvm::Timer> FrontendTimer;
- /// \brief The ASTReader, if one exists.
+ /// The ASTReader, if one exists.
IntrusiveRefCntPtr<ASTReader> ModuleManager;
- /// \brief The module dependency collector for crashdumps
+ /// The module dependency collector for crashdumps
std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector;
- /// \brief The module provider.
+ /// The module provider.
std::shared_ptr<PCHContainerOperations> ThePCHContainerOperations;
- /// \brief The dependency file generator.
+ /// The dependency file generator.
std::unique_ptr<DependencyFileGenerator> TheDependencyFileGenerator;
std::vector<std::shared_ptr<DependencyCollector>> DependencyCollectors;
- /// \brief The set of top-level modules that has already been loaded,
+ /// The set of top-level modules that has already been loaded,
/// along with the module map
llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules;
- /// \brief The set of top-level modules that has already been built on the
+ /// The set of top-level modules that has already been built on the
/// fly as part of this overall compilation action.
std::map<std::string, std::string> BuiltModules;
/// Should we delete the BuiltModules when we're done?
bool DeleteBuiltModules = true;
- /// \brief The location of the module-import keyword for the last module
+ /// The location of the module-import keyword for the last module
/// import.
SourceLocation LastModuleImportLoc;
- /// \brief The result of the last module import.
+ /// The result of the last module import.
///
ModuleLoadResult LastModuleImportResult;
- /// \brief Whether we should (re)build the global module index once we
+ /// Whether we should (re)build the global module index once we
/// have finished with this translation unit.
bool BuildGlobalModuleIndex = false;
- /// \brief We have a full global module index, with all modules.
+ /// We have a full global module index, with all modules.
bool HaveFullGlobalModuleIndex = false;
- /// \brief One or more modules failed to build.
+ /// One or more modules failed to build.
bool ModuleBuildFailed = false;
- /// \brief Holds information about the output file.
+ /// 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
@@ -183,6 +183,9 @@ class CompilerInstance : public ModuleLoader {
/// The list of active output files.
std::list<OutputFile> OutputFiles;
+ /// Force an output buffer.
+ std::unique_ptr<llvm::raw_pwrite_stream> OutputStream;
+
CompilerInstance(const CompilerInstance &) = delete;
void operator=(const CompilerInstance &) = delete;
public:
@@ -241,10 +244,10 @@ public:
/// setInvocation - Replace the current invocation.
void setInvocation(std::shared_ptr<CompilerInvocation> Value);
- /// \brief Indicates whether we should (re)build the global module index.
+ /// Indicates whether we should (re)build the global module index.
bool shouldBuildGlobalModuleIndex() const;
- /// \brief Set the flag indicating whether we should (re)build the global
+ /// Set the flag indicating whether we should (re)build the global
/// module index.
void setBuildGlobalModuleIndex(bool Build) {
BuildGlobalModuleIndex = Build;
@@ -387,7 +390,7 @@ public:
return *VirtualFileSystem;
}
- /// \brief Replace the current virtual file system.
+ /// Replace the current virtual file system.
///
/// \note Most clients should use setFileManager, which will implicitly reset
/// the virtual file system to the one contained in the file manager.
@@ -412,7 +415,7 @@ public:
FileMgr.resetWithoutRelease();
}
- /// \brief Replace the current file manager and virtual file system.
+ /// Replace the current file manager and virtual file system.
void setFileManager(FileManager *Value);
/// }
@@ -475,7 +478,7 @@ public:
/// setASTContext - Replace the current AST context.
void setASTContext(ASTContext *Value);
- /// \brief Replace the current Sema; the compiler instance takes ownership
+ /// Replace the current Sema; the compiler instance takes ownership
/// of S.
void setSema(Sema *S);
@@ -687,7 +690,7 @@ public:
Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column,
const CodeCompleteOptions &Opts, raw_ostream &OS);
- /// \brief Create the Sema object to be used for parsing.
+ /// Create the Sema object to be used for parsing.
void createSema(TranslationUnitKind TUKind,
CodeCompleteConsumer *CompletionConsumer);
@@ -773,6 +776,14 @@ public:
/// }
+ void setOutputStream(std::unique_ptr<llvm::raw_pwrite_stream> OutStream) {
+ OutputStream = std::move(OutStream);
+ }
+
+ std::unique_ptr<llvm::raw_pwrite_stream> takeOutputStream() {
+ return std::move(OutputStream);
+ }
+
// Create module manager.
void createModuleManager();
diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h
index 8c4c932190bc..3d302051d298 100644
--- a/include/clang/Frontend/CompilerInvocation.h
+++ b/include/clang/Frontend/CompilerInvocation.h
@@ -1,4 +1,4 @@
-//===-- CompilerInvocation.h - Compiler Invocation Helper Data --*- C++ -*-===//
+//===- CompilerInvocation.h - Compiler Invocation Helper Data ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,11 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_
-#define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_
+#ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H
+#define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_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"
@@ -21,25 +22,29 @@
#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include <memory>
#include <string>
namespace llvm {
+
class Triple;
namespace opt {
+
class ArgList;
-}
-}
+
+} // namespace opt
+
+} // namespace llvm
namespace clang {
-class PreprocessorOptions;
+
+class DiagnosticsEngine;
class HeaderSearchOptions;
+class PreprocessorOptions;
class TargetOptions;
-class LangOptions;
-class CompilerInvocation;
-class DiagnosticsEngine;
-/// \brief Fill out Opts based on the options given in Args.
+/// Fill out Opts based on the options given in Args.
///
/// Args must have been created from the OptTable returned by
/// createCC1OptTable().
@@ -52,8 +57,6 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
bool DefaultShowOpt = true);
class CompilerInvocationBase {
- void operator=(const CompilerInvocationBase &) = delete;
-
public:
/// Options controlling the language variant.
std::shared_ptr<LangOptions> LangOpts;
@@ -71,24 +74,24 @@ public:
std::shared_ptr<PreprocessorOptions> PreprocessorOpts;
CompilerInvocationBase();
- ~CompilerInvocationBase();
-
CompilerInvocationBase(const CompilerInvocationBase &X);
+ CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete;
+ ~CompilerInvocationBase();
LangOptions *getLangOpts() { return LangOpts.get(); }
const LangOptions *getLangOpts() const { return LangOpts.get(); }
TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
- const TargetOptions &getTargetOpts() const {
- return *TargetOpts.get();
- }
+ const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
+
const HeaderSearchOptions &getHeaderSearchOpts() const {
return *HeaderSearchOpts;
}
+
std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const {
return HeaderSearchOpts;
}
@@ -96,13 +99,15 @@ public:
std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr() {
return PreprocessorOpts;
}
+
PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
+
const PreprocessorOptions &getPreprocessorOpts() const {
return *PreprocessorOpts;
}
};
-/// \brief Helper class for holding the data necessary to invoke the compiler.
+/// Helper class for holding the data necessary to invoke the compiler.
///
/// This class is designed to represent an abstract "invocation" of the
/// compiler, including data such as the include paths, the code generation
@@ -134,7 +139,7 @@ public:
/// @name Utility Methods
/// @{
- /// \brief Create a compiler invocation from a list of input options.
+ /// Create a compiler invocation from a list of input options.
/// \returns true on success.
///
/// \param [out] Res - The resulting invocation.
@@ -146,7 +151,7 @@ public:
const char* const *ArgEnd,
DiagnosticsEngine &Diags);
- /// \brief Get the directory where the compiler headers
+ /// Get the directory where the compiler headers
/// reside, relative to the compiler binary (found by the passed in
/// arguments).
///
@@ -156,7 +161,7 @@ public:
/// executable), for finding the builtin compiler path.
static std::string GetResourcesPath(const char *Argv0, void *MainAddr);
- /// \brief Set language defaults for the given input language and
+ /// Set language defaults for the given input language and
/// language standard in the given LangOptions object.
///
/// \param Opts - The LangOptions object to set up.
@@ -168,7 +173,7 @@ public:
const llvm::Triple &T, PreprocessorOptions &PPOpts,
LangStandard::Kind LangStd = LangStandard::lang_unspecified);
- /// \brief Retrieve a module hash string that is suitable for uniquely
+ /// Retrieve a module hash string that is suitable for uniquely
/// identifying the conditions under which the module was built.
std::string getModuleHash() const;
@@ -176,40 +181,35 @@ public:
/// @name Option Subgroups
/// @{
- AnalyzerOptionsRef getAnalyzerOpts() const {
- return AnalyzerOpts;
- }
+ AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
MigratorOptions &getMigratorOpts() { return MigratorOpts; }
- const MigratorOptions &getMigratorOpts() const {
- return MigratorOpts;
- }
+ const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
- const CodeGenOptions &getCodeGenOpts() const {
- return CodeGenOpts;
- }
+ const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
DependencyOutputOptions &getDependencyOutputOpts() {
return DependencyOutputOpts;
}
+
const DependencyOutputOptions &getDependencyOutputOpts() const {
return DependencyOutputOpts;
}
FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
+
const FileSystemOptions &getFileSystemOpts() const {
return FileSystemOpts;
}
FrontendOptions &getFrontendOpts() { return FrontendOpts; }
- const FrontendOptions &getFrontendOpts() const {
- return FrontendOpts;
- }
+ const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
PreprocessorOutputOptions &getPreprocessorOutputOpts() {
return PreprocessorOutputOpts;
}
+
const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
return PreprocessorOutputOpts;
}
@@ -218,8 +218,10 @@ public:
};
namespace vfs {
- class FileSystem;
-}
+
+class FileSystem;
+
+} // namespace vfs
IntrusiveRefCntPtr<vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
@@ -230,6 +232,6 @@ createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS);
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H
diff --git a/include/clang/Frontend/DependencyOutputOptions.h b/include/clang/Frontend/DependencyOutputOptions.h
index 0be36cd9aa6e..f419d2643649 100644
--- a/include/clang/Frontend/DependencyOutputOptions.h
+++ b/include/clang/Frontend/DependencyOutputOptions.h
@@ -15,6 +15,9 @@
namespace clang {
+/// ShowIncludesDestination - Destination for /showIncludes output.
+enum class ShowIncludesDestination { None, Stdout, Stderr };
+
/// DependencyOutputFormat - Format for the compiler dependency file.
enum class DependencyOutputFormat { Make, NMake };
@@ -28,11 +31,13 @@ public:
/// dependency, which can avoid some 'make'
/// problems.
unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
- unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info.
unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
+ /// Destination of cl.exe style /showIncludes info.
+ ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
+
/// The format for the dependency file.
- DependencyOutputFormat OutputFormat;
+ DependencyOutputFormat OutputFormat = DependencyOutputFormat::Make;
/// The file to write dependency output to.
std::string OutputFile;
@@ -53,22 +58,16 @@ public:
/// In /showIncludes mode, pretend the main TU is a header with this name.
std::string ShowIncludesPretendHeader;
- /// \brief The file to write GraphViz-formatted header dependencies to.
+ /// The file to write GraphViz-formatted header dependencies to.
std::string DOTOutputFile;
- /// \brief The directory to copy module dependencies to when collecting them.
+ /// The directory to copy module dependencies to when collecting them.
std::string ModuleDependencyOutputDir;
public:
- DependencyOutputOptions() {
- IncludeSystemHeaders = 0;
- ShowHeaderIncludes = 0;
- UsePhonyTargets = 0;
- AddMissingHeaderDeps = 0;
- PrintShowIncludes = 0;
- IncludeModuleFiles = 0;
- OutputFormat = DependencyOutputFormat::Make;
- }
+ DependencyOutputOptions()
+ : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
+ AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
};
} // end namespace clang
diff --git a/include/clang/Frontend/DiagnosticRenderer.h b/include/clang/Frontend/DiagnosticRenderer.h
index e453d7db624c..191d32accf2f 100644
--- a/include/clang/Frontend/DiagnosticRenderer.h
+++ b/include/clang/Frontend/DiagnosticRenderer.h
@@ -1,4 +1,4 @@
-//===--- DiagnosticRenderer.h - Diagnostic Pretty-Printing ------*- C++ -*-===//
+//===- DiagnosticRenderer.h - Diagnostic Pretty-Printing --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,20 +17,23 @@
#define LLVM_CLANG_FRONTEND_DIAGNOSTICRENDERER_H
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/StringRef.h"
namespace clang {
-class DiagnosticOptions;
class LangOptions;
class SourceManager;
-typedef llvm::PointerUnion<const Diagnostic *,
- const StoredDiagnostic *> DiagOrStoredDiag;
+using DiagOrStoredDiag =
+ llvm::PointerUnion<const Diagnostic *, const StoredDiagnostic *>;
-/// \brief Class to encapsulate the logic for formatting a diagnostic message.
+/// Class to encapsulate the logic for formatting a diagnostic message.
///
/// Actual "printing" logic is implemented by subclasses.
///
@@ -47,24 +50,24 @@ protected:
const LangOptions &LangOpts;
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
- /// \brief The location of the previous diagnostic if known.
+ /// The location of the previous diagnostic if known.
///
/// This will be invalid in cases where there is no (known) previous
/// diagnostic location, or that location itself is invalid or comes from
/// a different source manager than SM.
SourceLocation LastLoc;
- /// \brief The location of the last include whose stack was printed if known.
+ /// The location of the last include whose stack was printed if known.
///
/// Same restriction as LastLoc essentially, but tracking include stack
/// root locations rather than diagnostic locations.
SourceLocation LastIncludeLoc;
- /// \brief The level of the last diagnostic emitted.
+ /// The level of the last diagnostic emitted.
///
/// The level of the last diagnostic emitted. Used to detect level changes
/// which change the amount of information displayed.
- DiagnosticsEngine::Level LastLevel;
+ DiagnosticsEngine::Level LastLevel = DiagnosticsEngine::Ignored;
DiagnosticRenderer(const LangOptions &LangOpts,
DiagnosticOptions *DiagOpts);
@@ -97,7 +100,6 @@ protected:
virtual void endDiagnostic(DiagOrStoredDiag D,
DiagnosticsEngine::Level Level) {}
-
private:
void emitBasicNote(StringRef Message);
void emitIncludeStack(FullSourceLoc Loc, PresumedLoc PLoc,
@@ -116,7 +118,7 @@ private:
ArrayRef<FixItHint> Hints);
public:
- /// \brief Emit a diagnostic.
+ /// Emit a diagnostic.
///
/// This is the primary entry point for emitting diagnostic messages.
/// It handles formatting and rendering the message as well as any ancillary
@@ -142,7 +144,7 @@ class DiagnosticNoteRenderer : public DiagnosticRenderer {
public:
DiagnosticNoteRenderer(const LangOptions &LangOpts,
DiagnosticOptions *DiagOpts)
- : DiagnosticRenderer(LangOpts, DiagOpts) {}
+ : DiagnosticRenderer(LangOpts, DiagOpts) {}
~DiagnosticNoteRenderer() override;
@@ -156,5 +158,7 @@ public:
virtual void emitNote(FullSourceLoc Loc, StringRef Message) = 0;
};
-} // end clang namespace
-#endif
+
+} // namespace clang
+
+#endif // LLVM_CLANG_FRONTEND_DIAGNOSTICRENDERER_H
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h
index 7ae6173512a6..2a4077d34391 100644
--- a/include/clang/Frontend/FrontendAction.h
+++ b/include/clang/Frontend/FrontendAction.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
///
/// \file
-/// \brief Defines the clang::FrontendAction interface and various convenience
+/// Defines the clang::FrontendAction interface and various convenience
/// abstract classes (clang::ASTFrontendAction, clang::PluginASTAction,
/// clang::PreprocessorFrontendAction, and clang::WrapperFrontendAction)
/// derived from it.
@@ -48,7 +48,7 @@ protected:
/// @name Implementation Action Interface
/// @{
- /// \brief Create the AST consumer object for this action, if supported.
+ /// Create the AST consumer object for this action, if supported.
///
/// This routine is called as part of BeginSourceFile(), which will
/// fail if the AST consumer cannot be created. This will not be called if the
@@ -64,7 +64,7 @@ protected:
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) = 0;
- /// \brief Callback before starting processing a single input, giving the
+ /// Callback before starting processing a single input, giving the
/// opportunity to modify the CompilerInvocation or do some other action
/// before BeginSourceFileAction is called.
///
@@ -72,7 +72,7 @@ protected:
/// ExecuteAction() and EndSourceFileAction() will not be called.
virtual bool BeginInvocation(CompilerInstance &CI) { return true; }
- /// \brief Callback at the start of processing a single input.
+ /// Callback at the start of processing a single input.
///
/// \return True on success; on failure ExecutionAction() and
/// EndSourceFileAction() will not be called.
@@ -80,20 +80,20 @@ protected:
return true;
}
- /// \brief Callback to run the program action, using the initialized
+ /// Callback to run the program action, using the initialized
/// compiler instance.
///
/// This is guaranteed to only be called between BeginSourceFileAction()
/// and EndSourceFileAction().
virtual void ExecuteAction() = 0;
- /// \brief Callback at the end of processing a single input.
+ /// Callback at the end of processing a single input.
///
/// This is guaranteed to only be called following a successful call to
/// BeginSourceFileAction (and BeginSourceFile).
virtual void EndSourceFileAction() {}
- /// \brief Callback at the end of processing a single input, to determine
+ /// Callback at the end of processing a single input, to determine
/// if the output files should be erased or not.
///
/// By default it returns true if a compiler error occurred.
@@ -158,39 +158,39 @@ public:
/// @name Supported Modes
/// @{
- /// \brief Is this action invoked on a model file?
+ /// Is this action invoked on a model file?
///
/// Model files are incomplete translation units that relies on type
/// information from another translation unit. Check ParseModelFileAction for
/// details.
virtual bool isModelParsingAction() const { return false; }
- /// \brief Does this action only use the preprocessor?
+ /// Does this action only use the preprocessor?
///
/// If so no AST context will be created and this action will be invalid
/// with AST file inputs.
virtual bool usesPreprocessorOnly() const = 0;
- /// \brief For AST-based actions, the kind of translation unit we're handling.
+ /// For AST-based actions, the kind of translation unit we're handling.
virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; }
- /// \brief Does this action support use with PCH?
+ /// Does this action support use with PCH?
virtual bool hasPCHSupport() const { return true; }
- /// \brief Does this action support use with AST files?
+ /// Does this action support use with AST files?
virtual bool hasASTFileSupport() const { return true; }
- /// \brief Does this action support use with IR files?
+ /// Does this action support use with IR files?
virtual bool hasIRSupport() const { return false; }
- /// \brief Does this action support use with code completion?
+ /// Does this action support use with code completion?
virtual bool hasCodeCompletionSupport() const { return false; }
/// @}
/// @name Public Action Interface
/// @{
- /// \brief Prepare the action for processing the input file \p Input.
+ /// Prepare the action for processing the input file \p Input.
///
/// This is run after the options and frontend have been initialized,
/// but prior to executing any per-file processing.
@@ -211,20 +211,20 @@ public:
/// be aborted and neither Execute() nor EndSourceFile() should be called.
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input);
- /// \brief Set the source manager's main input file, and run the action.
+ /// Set the source manager's main input file, and run the action.
bool Execute();
- /// \brief Perform any per-file post processing, deallocate per-file
+ /// Perform any per-file post processing, deallocate per-file
/// objects, and run statistics and output file cleanup code.
void EndSourceFile();
/// @}
};
-/// \brief Abstract base class to use for AST consumer-based frontend actions.
+/// Abstract base class to use for AST consumer-based frontend actions.
class ASTFrontendAction : public FrontendAction {
protected:
- /// \brief Implement the ExecuteAction interface by running Sema on
+ /// Implement the ExecuteAction interface by running Sema on
/// the already-initialized AST consumer.
///
/// This will also take care of instantiating a code completion consumer if
@@ -242,7 +242,7 @@ public:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override = 0;
- /// \brief Parse the given plugin command line arguments.
+ /// Parse the given plugin command line arguments.
///
/// \param CI - The compiler instance, for use in reporting diagnostics.
/// \return True if the parsing succeeded; otherwise the plugin will be
@@ -257,7 +257,7 @@ public:
AddBeforeMainAction, ///< Execute the action before the main action
AddAfterMainAction ///< Execute the action after the main action
};
- /// \brief Get the action type for this plugin
+ /// Get the action type for this plugin
///
/// \return The action type. If the type is Cmdline then by default the
/// plugin does nothing and what it does is determined by the cc1
@@ -265,10 +265,10 @@ public:
virtual ActionType getActionType() { return Cmdline; }
};
-/// \brief Abstract base class to use for preprocessor-based frontend actions.
+/// Abstract base class to use for preprocessor-based frontend actions.
class PreprocessorFrontendAction : public FrontendAction {
protected:
- /// \brief Provide a default implementation which returns aborts;
+ /// Provide a default implementation which returns aborts;
/// this method should never be called by FrontendAction clients.
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override;
@@ -277,7 +277,7 @@ public:
bool usesPreprocessorOnly() const override { return true; }
};
-/// \brief A frontend action which simply wraps some other runtime-specified
+/// A frontend action which simply wraps some other runtime-specified
/// frontend action.
///
/// Deriving from this class allows an action to inject custom logic around
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index fa1529a3d65d..20f1b3e11bdb 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -35,6 +35,18 @@ public:
bool usesPreprocessorOnly() const override { return false; }
};
+class DumpCompilerOptionsAction : public FrontendAction {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override {
+ return nullptr;
+ }
+
+ void ExecuteAction() override;
+
+public:
+ bool usesPreprocessorOnly() const override { return true; }
+};
+
//===----------------------------------------------------------------------===//
// AST Consumer Actions
//===----------------------------------------------------------------------===//
@@ -83,14 +95,14 @@ protected:
bool shouldEraseOutputFiles() override;
public:
- /// \brief Compute the AST consumer arguments that will be used to
+ /// Compute the AST consumer arguments that will be used to
/// create the PCHGenerator instance returned by CreateASTConsumer.
///
/// \returns false if an error occurred, true otherwise.
static bool ComputeASTConsumerArguments(CompilerInstance &CI,
std::string &Sysroot);
- /// \brief Creates file to write the PCH into and returns a stream to write it
+ /// Creates file to write the PCH into and returns a stream to write it
/// into. On error, returns null.
static std::unique_ptr<llvm::raw_pwrite_stream>
CreateOutputFile(CompilerInstance &CI, StringRef InFile,
@@ -140,7 +152,7 @@ public:
bool hasCodeCompletionSupport() const override { return true; }
};
-/// \brief Dump information about the given module file, to be used for
+/// Dump information about the given module file, to be used for
/// basic debugging and discovery.
class DumpModuleInfoAction : public ASTFrontendAction {
protected:
@@ -167,8 +179,16 @@ public:
bool hasCodeCompletionSupport() const override { return false; }
};
+class TemplightDumpAction : public ASTFrontendAction {
+protected:
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override;
+
+ void ExecuteAction() override;
+};
+
/**
- * \brief Frontend action adaptor that merges ASTs together.
+ * Frontend action adaptor that merges ASTs together.
*
* This action takes an existing AST file and "merges" it into the AST
* context, producing a merged context. This action is an action
@@ -176,10 +196,10 @@ public:
* will consume the merged context.
*/
class ASTMergeAction : public FrontendAction {
- /// \brief The action that the merge action adapts.
+ /// The action that the merge action adapts.
std::unique_ptr<FrontendAction> AdaptedAction;
- /// \brief The set of AST files to merge.
+ /// The set of AST files to merge.
std::vector<std::string> ASTFiles;
protected:
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 5192a3774cc1..668df83274eb 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -1,4 +1,4 @@
-//===--- FrontendOptions.h --------------------------------------*- C++ -*-===//
+//===- FrontendOptions.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,54 +14,127 @@
#include "clang/Serialization/ModuleFileExtension.h"
#include "clang/Sema/CodeCompleteOptions.h"
#include "llvm/ADT/StringRef.h"
+#include <cassert>
+#include <memory>
#include <string>
#include <vector>
#include <unordered_map>
namespace llvm {
+
class MemoryBuffer;
-}
+
+} // namespace llvm
namespace clang {
-class FileEntry;
namespace frontend {
- enum ActionKind {
- ASTDeclList, ///< Parse ASTs and list Decl nodes.
- ASTDump, ///< Parse ASTs and dump them.
- ASTPrint, ///< Parse ASTs and print them.
- ASTView, ///< Parse ASTs and view them in Graphviz.
- DumpRawTokens, ///< Dump out raw tokens.
- DumpTokens, ///< Dump out preprocessed tokens.
- EmitAssembly, ///< Emit a .s file.
- EmitBC, ///< Emit a .bc file.
- EmitHTML, ///< Translate input source into HTML.
- EmitLLVM, ///< Emit a .ll file.
- EmitLLVMOnly, ///< Generate LLVM IR, but do not emit anything.
- 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 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.
- ModuleFileInfo, ///< Dump information about a module file.
- VerifyPCH, ///< Load and verify that a PCH file is usable.
- ParseSyntaxOnly, ///< Parse and perform semantic analysis.
- PluginAction, ///< Run a plugin action, \see ActionName.
- PrintDeclContext, ///< Print DeclContext and their Decls.
- PrintPreamble, ///< Print the "preamble" of the input file
- PrintPreprocessedInput, ///< -E mode.
- RewriteMacros, ///< Expand macros but not \#includes.
- RewriteObjC, ///< ObjC->C Rewriter.
- RewriteTest, ///< Rewriter playground
- RunAnalysis, ///< Run one or more source code analyses.
- MigrateSource, ///< Run migrator.
- RunPreprocessorOnly ///< Just lex, no output.
- };
-}
+
+enum ActionKind {
+ /// Parse ASTs and list Decl nodes.
+ ASTDeclList,
+
+ /// Parse ASTs and dump them.
+ ASTDump,
+
+ /// Parse ASTs and print them.
+ ASTPrint,
+
+ /// Parse ASTs and view them in Graphviz.
+ ASTView,
+
+ /// Dump the compiler configuration.
+ DumpCompilerOptions,
+
+ /// Dump out raw tokens.
+ DumpRawTokens,
+
+ /// Dump out preprocessed tokens.
+ DumpTokens,
+
+ /// Emit a .s file.
+ EmitAssembly,
+
+ /// Emit a .bc file.
+ EmitBC,
+
+ /// Translate input source into HTML.
+ EmitHTML,
+
+ /// Emit a .ll file.
+ EmitLLVM,
+
+ /// Generate LLVM IR, but do not emit anything.
+ EmitLLVMOnly,
+
+ /// Generate machine code, but don't emit anything.
+ EmitCodeGenOnly,
+
+ /// Emit a .o file.
+ EmitObj,
+
+ /// Parse and apply any fixits to the source.
+ FixIt,
+
+ /// Generate pre-compiled module from a module map.
+ GenerateModule,
+
+ /// Generate pre-compiled module from a C++ module interface file.
+ GenerateModuleInterface,
+
+ /// Generate pre-compiled header.
+ GeneratePCH,
+
+ /// Generate pre-tokenized header.
+ GeneratePTH,
+
+ /// Only execute frontend initialization.
+ InitOnly,
+
+ /// Dump information about a module file.
+ ModuleFileInfo,
+
+ /// Load and verify that a PCH file is usable.
+ VerifyPCH,
+
+ /// Parse and perform semantic analysis.
+ ParseSyntaxOnly,
+
+ /// Run a plugin action, \see ActionName.
+ PluginAction,
+
+ /// Print DeclContext and their Decls.
+ PrintDeclContext,
+
+ /// Print the "preamble" of the input file
+ PrintPreamble,
+
+ /// -E mode.
+ PrintPreprocessedInput,
+
+ /// Expand macros but not \#includes.
+ RewriteMacros,
+
+ /// ObjC->C Rewriter.
+ RewriteObjC,
+
+ /// Rewriter playground
+ RewriteTest,
+
+ /// Run one or more source code analyses.
+ RunAnalysis,
+
+ /// Dump template instantiations
+ TemplightDump,
+
+ /// Run migrator.
+ MigrateSource,
+
+ /// Just lex, no output.
+ RunPreprocessorOnly
+};
+
+} // namespace frontend
/// The kind of a file that we've been handed as an input.
class InputKind {
@@ -91,6 +164,7 @@ public:
OpenCL,
CUDA,
RenderScript,
+ HIP,
///@}
};
@@ -118,14 +192,15 @@ public:
InputKind getPreprocessed() const {
return InputKind(getLanguage(), getFormat(), true);
}
+
InputKind withFormat(Format F) const {
return InputKind(getLanguage(), F, isPreprocessed());
}
};
-/// \brief An input file for the front end.
+/// An input file for the front end.
class FrontendInputFile {
- /// \brief The file name, or "-" to read from standard input.
+ /// The file name, or "-" to read from standard input.
std::string File;
/// The input, if it comes from a buffer rather than a file. This object
@@ -133,19 +208,19 @@ class FrontendInputFile {
/// that it outlives any users.
llvm::MemoryBuffer *Buffer = nullptr;
- /// \brief The kind of input, e.g., C source, AST file, LLVM IR.
+ /// The kind of input, e.g., C source, AST file, LLVM IR.
InputKind Kind;
- /// \brief Whether we're dealing with a 'system' input (vs. a 'user' input).
+ /// Whether we're dealing with a 'system' input (vs. a 'user' input).
bool IsSystem = false;
public:
- FrontendInputFile() { }
+ FrontendInputFile() = default;
FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false)
- : File(File.str()), Kind(Kind), IsSystem(IsSystem) { }
+ : File(File.str()), Kind(Kind), IsSystem(IsSystem) {}
FrontendInputFile(llvm::MemoryBuffer *Buffer, InputKind Kind,
bool IsSystem = false)
- : Buffer(Buffer), Kind(Kind), IsSystem(IsSystem) { }
+ : Buffer(Buffer), Kind(Kind), IsSystem(IsSystem) {}
InputKind getKind() const { return Kind; }
bool isSystem() const { return IsSystem; }
@@ -159,6 +234,7 @@ public:
assert(isFile());
return File;
}
+
llvm::MemoryBuffer *getBuffer() const {
assert(isBuffer());
return Buffer;
@@ -168,43 +244,67 @@ public:
/// FrontendOptions - Options for controlling the behavior of the frontend.
class FrontendOptions {
public:
- unsigned DisableFree : 1; ///< Disable memory freeing on exit.
- unsigned RelocatablePCH : 1; ///< When generating PCH files,
- /// instruct the AST writer to create
- /// relocatable PCH files.
- unsigned ShowHelp : 1; ///< Show the -help text.
- unsigned ShowStats : 1; ///< Show frontend performance
- /// metrics and statistics.
- unsigned ShowTimers : 1; ///< Show timers for individual
- /// actions.
- unsigned ShowVersion : 1; ///< Show the -version text.
- unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are
- /// unfixable errors.
- unsigned FixOnlyWarnings : 1; ///< Apply fixes only for warnings.
- unsigned FixAndRecompile : 1; ///< Apply fixes and recompile.
- unsigned FixToTemporaries : 1; ///< Apply fixes to temporary files.
- unsigned ARCMTMigrateEmitARCErrors : 1; /// Emit ARC errors even if the
- /// migrator can fix them
- unsigned SkipFunctionBodies : 1; ///< Skip over function bodies to
- /// speed up parsing in cases you do
- /// not need them (e.g. with code
- /// completion).
- unsigned UseGlobalModuleIndex : 1; ///< Whether we can use the
- ///< global module index if available.
- unsigned GenerateGlobalModuleIndex : 1; ///< Whether we can generate the
- ///< global module index if needed.
- unsigned ASTDumpDecls : 1; ///< Whether we include declaration
- ///< dumps in AST dumps.
- unsigned ASTDumpAll : 1; ///< Whether we deserialize all decls
- ///< when forming AST dumps.
- unsigned ASTDumpLookups : 1; ///< Whether we include lookup table
- ///< dumps in AST dumps.
- unsigned BuildingImplicitModule : 1; ///< Whether we are performing an
- ///< implicit module build.
- unsigned ModulesEmbedAllFiles : 1; ///< Whether we should embed all used
- ///< files into the PCM file.
- unsigned IncludeTimestamps : 1; ///< Whether timestamps should be
- ///< written to the produced PCH file.
+ /// Disable memory freeing on exit.
+ unsigned DisableFree : 1;
+
+ /// When generating PCH files, instruct the AST writer to create relocatable
+ /// PCH files.
+ unsigned RelocatablePCH : 1;
+
+ /// Show the -help text.
+ unsigned ShowHelp : 1;
+
+ /// Show frontend performance metrics and statistics.
+ unsigned ShowStats : 1;
+
+ /// Show timers for individual actions.
+ unsigned ShowTimers : 1;
+
+ /// Show the -version text.
+ unsigned ShowVersion : 1;
+
+ /// Apply fixes even if there are unfixable errors.
+ unsigned FixWhatYouCan : 1;
+
+ /// Apply fixes only for warnings.
+ unsigned FixOnlyWarnings : 1;
+
+ /// Apply fixes and recompile.
+ unsigned FixAndRecompile : 1;
+
+ /// Apply fixes to temporary files.
+ unsigned FixToTemporaries : 1;
+
+ /// Emit ARC errors even if the migrator can fix them.
+ unsigned ARCMTMigrateEmitARCErrors : 1;
+
+ /// Skip over function bodies to speed up parsing in cases you do not need
+ /// them (e.g. with code completion).
+ unsigned SkipFunctionBodies : 1;
+
+ /// Whether we can use the global module index if available.
+ unsigned UseGlobalModuleIndex : 1;
+
+ /// Whether we can generate the global module index if needed.
+ unsigned GenerateGlobalModuleIndex : 1;
+
+ /// Whether we include declaration dumps in AST dumps.
+ unsigned ASTDumpDecls : 1;
+
+ /// Whether we deserialize all decls when forming AST dumps.
+ unsigned ASTDumpAll : 1;
+
+ /// Whether we include lookup table dumps in AST dumps.
+ unsigned ASTDumpLookups : 1;
+
+ /// Whether we are performing an implicit module build.
+ unsigned BuildingImplicitModule : 1;
+
+ /// Whether we should embed all used files into the PCM file.
+ unsigned ModulesEmbedAllFiles : 1;
+
+ /// Whether timestamps should be written to the produced PCH file.
+ unsigned IncludeTimestamps : 1;
CodeCompleteOptions CodeCompleteOpts;
@@ -213,38 +313,53 @@ public:
ARCMT_Check,
ARCMT_Modify,
ARCMT_Migrate
- } ARCMTAction;
+ } ARCMTAction = ARCMT_None;
enum {
ObjCMT_None = 0,
- /// \brief Enable migration to modern ObjC literals.
+
+ /// Enable migration to modern ObjC literals.
ObjCMT_Literals = 0x1,
- /// \brief Enable migration to modern ObjC subscripting.
+
+ /// Enable migration to modern ObjC subscripting.
ObjCMT_Subscripting = 0x2,
- /// \brief Enable migration to modern ObjC readonly property.
+
+ /// Enable migration to modern ObjC readonly property.
ObjCMT_ReadonlyProperty = 0x4,
- /// \brief Enable migration to modern ObjC readwrite property.
+
+ /// Enable migration to modern ObjC readwrite property.
ObjCMT_ReadwriteProperty = 0x8,
- /// \brief Enable migration to modern ObjC property.
+
+ /// Enable migration to modern ObjC property.
ObjCMT_Property = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty),
- /// \brief Enable annotation of ObjCMethods of all kinds.
+
+ /// Enable annotation of ObjCMethods of all kinds.
ObjCMT_Annotation = 0x10,
- /// \brief Enable migration of ObjC methods to 'instancetype'.
+
+ /// Enable migration of ObjC methods to 'instancetype'.
ObjCMT_Instancetype = 0x20,
- /// \brief Enable migration to NS_ENUM/NS_OPTIONS macros.
+
+ /// Enable migration to NS_ENUM/NS_OPTIONS macros.
ObjCMT_NsMacros = 0x40,
- /// \brief Enable migration to add conforming protocols.
+
+ /// Enable migration to add conforming protocols.
ObjCMT_ProtocolConformance = 0x80,
- /// \brief prefer 'atomic' property over 'nonatomic'.
+
+ /// prefer 'atomic' property over 'nonatomic'.
ObjCMT_AtomicProperty = 0x100,
- /// \brief annotate property with NS_RETURNS_INNER_POINTER
+
+ /// annotate property with NS_RETURNS_INNER_POINTER
ObjCMT_ReturnsInnerPointerProperty = 0x200,
- /// \brief use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
+
+ /// use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
ObjCMT_NsAtomicIOSOnlyProperty = 0x400,
- /// \brief Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
+
+ /// Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
ObjCMT_DesignatedInitializer = 0x800,
- /// \brief Enable converting setter/getter expressions to property-dot syntx.
+
+ /// Enable converting setter/getter expressions to property-dot syntx.
ObjCMT_PropertyDotSyntax = 0x1000,
+
ObjCMT_MigrateDecls = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty |
ObjCMT_Annotation | ObjCMT_Instancetype |
ObjCMT_NsMacros | ObjCMT_ProtocolConformance |
@@ -253,7 +368,7 @@ public:
ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting |
ObjCMT_MigrateDecls | ObjCMT_PropertyDotSyntax)
};
- unsigned ObjCMTAction;
+ unsigned ObjCMTAction = ObjCMT_None;
std::string ObjCMTWhiteListPath;
std::string MTMigrateDir;
@@ -279,7 +394,7 @@ public:
ParsedSourceLocation CodeCompletionAt;
/// The frontend action to perform.
- frontend::ActionKind ProgramAction;
+ frontend::ActionKind ProgramAction = frontend::ParseSyntaxOnly;
/// The name of the action to run when using a plugin action.
std::string ActionName;
@@ -296,49 +411,43 @@ public:
/// The list of module file extensions.
std::vector<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
- /// \brief The list of module map files to load before processing the input.
+ /// The list of module map files to load before processing the input.
std::vector<std::string> ModuleMapFiles;
- /// \brief The list of additional prebuilt module files to load before
+ /// The list of additional prebuilt module files to load before
/// processing the input.
std::vector<std::string> ModuleFiles;
- /// \brief The list of files to embed into the compiled module file.
+ /// The list of files to embed into the compiled module file.
std::vector<std::string> ModulesEmbedFiles;
- /// \brief The list of AST files to merge.
+ /// The list of AST files to merge.
std::vector<std::string> ASTMergeFiles;
- /// \brief A list of arguments to forward to LLVM's option processing; this
+ /// A list of arguments to forward to LLVM's option processing; this
/// should only be used for debugging and experimental features.
std::vector<std::string> LLVMArgs;
- /// \brief File name of the file that will provide record layouts
+ /// File name of the file that will provide record layouts
/// (in the format produced by -fdump-record-layouts).
std::string OverrideRecordLayoutsFile;
- /// \brief Auxiliary triple for CUDA compilation.
+ /// Auxiliary triple for CUDA compilation.
std::string AuxTriple;
- /// \brief If non-empty, search the pch input file as if it was a header
- /// included by this file.
- std::string FindPchSource;
-
/// Filename to write statistics to.
std::string StatsFile;
public:
- FrontendOptions() :
- DisableFree(false), RelocatablePCH(false), ShowHelp(false),
- ShowStats(false), ShowTimers(false), ShowVersion(false),
- FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false),
- FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false),
- SkipFunctionBodies(false), UseGlobalModuleIndex(true),
- GenerateGlobalModuleIndex(true), ASTDumpDecls(false), ASTDumpLookups(false),
- BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
- IncludeTimestamps(true), ARCMTAction(ARCMT_None),
- ObjCMTAction(ObjCMT_None), ProgramAction(frontend::ParseSyntaxOnly)
- {}
+ FrontendOptions()
+ : DisableFree(false), RelocatablePCH(false), ShowHelp(false),
+ ShowStats(false), ShowTimers(false), ShowVersion(false),
+ FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false),
+ FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false),
+ SkipFunctionBodies(false), UseGlobalModuleIndex(true),
+ GenerateGlobalModuleIndex(true), ASTDumpDecls(false),
+ ASTDumpLookups(false), BuildingImplicitModule(false),
+ ModulesEmbedAllFiles(false), IncludeTimestamps(true) {}
/// getInputKindForExtension - Return the appropriate input kind for a file
/// extension. For example, "c" would return InputKind::C.
@@ -348,6 +457,6 @@ public:
static InputKind getInputKindForExtension(StringRef Extension);
};
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
diff --git a/include/clang/Frontend/FrontendPluginRegistry.h b/include/clang/Frontend/FrontendPluginRegistry.h
index 9d7ee08d95d4..9a85e89d905d 100644
--- a/include/clang/Frontend/FrontendPluginRegistry.h
+++ b/include/clang/Frontend/FrontendPluginRegistry.h
@@ -1,4 +1,4 @@
-//===-- FrontendAction.h - Pluggable Frontend Action Interface --*- C++ -*-===//
+//===- FrontendPluginRegistry.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,6 +6,10 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+//
+// Pluggable Frontend Action Interface
+//
+//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
#define LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
@@ -16,8 +20,8 @@
namespace clang {
/// The frontend plugin registry.
-typedef llvm::Registry<PluginASTAction> FrontendPluginRegistry;
+using FrontendPluginRegistry = llvm::Registry<PluginASTAction>;
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Frontend/LangStandards.def
index e7a081dc2aa7..1e895d785d15 100644
--- a/include/clang/Frontend/LangStandards.def
+++ b/include/clang/Frontend/LangStandards.def
@@ -155,6 +155,9 @@ LANGSTANDARD(opencl12, "cl1.2",
LANGSTANDARD(opencl20, "cl2.0",
OpenCL, "OpenCL 2.0",
LineComment | C99 | Digraphs | HexFloat | OpenCL)
+LANGSTANDARD(openclcpp, "c++",
+ OpenCL, "OpenCL C++ 1.0",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs | OpenCL)
LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
@@ -165,6 +168,10 @@ LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
LineComment | CPlusPlus | Digraphs)
+// HIP
+LANGSTANDARD(hip, "hip", HIP, "HIP",
+ LineComment | CPlusPlus | Digraphs)
+
#undef LANGSTANDARD
#undef LANGSTANDARD_ALIAS
#undef LANGSTANDARD_ALIAS_DEPR
diff --git a/include/clang/Frontend/LayoutOverrideSource.h b/include/clang/Frontend/LayoutOverrideSource.h
index 16d032b7dd72..0b7f7dc7a7d6 100644
--- a/include/clang/Frontend/LayoutOverrideSource.h
+++ b/include/clang/Frontend/LayoutOverrideSource.h
@@ -1,4 +1,4 @@
-//===--- LayoutOverrideSource.h --Override Record Layouts -----------------===//
+//===--- LayoutOverrideSource.h --Override Record Layouts -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,36 +16,36 @@
#include "llvm/ADT/StringRef.h"
namespace clang {
- /// \brief An external AST source that overrides the layout of
+ /// An external AST source that overrides the layout of
/// a specified set of record types.
///
/// This class is used only for testing the ability of external AST sources
/// to override the layout of record types. Its input is the output format
/// of the command-line argument -fdump-record-layouts.
class LayoutOverrideSource : public ExternalASTSource {
- /// \brief The layout of a given record.
+ /// The layout of a given record.
struct Layout {
- /// \brief The size of the record.
+ /// The size of the record.
uint64_t Size;
- /// \brief The alignment of the record.
+ /// The alignment of the record.
uint64_t Align;
- /// \brief The offsets of the fields, in source order.
+ /// The offsets of the fields, in source order.
SmallVector<uint64_t, 8> FieldOffsets;
};
- /// \brief The set of layouts that will be overridden.
+ /// The set of layouts that will be overridden.
llvm::StringMap<Layout> Layouts;
public:
- /// \brief Create a new AST source that overrides the layout of some
+ /// Create a new AST source that overrides the layout of some
/// set of record types.
///
/// The file is the result of passing -fdump-record-layouts to a file.
explicit LayoutOverrideSource(StringRef Filename);
- /// \brief If this particular record type has an overridden layout,
+ /// If this particular record type has an overridden layout,
/// return that layout.
bool
layoutRecordType(const RecordDecl *Record,
@@ -55,7 +55,7 @@ namespace clang {
llvm::DenseMap<const CXXRecordDecl *,
CharUnits> &VirtualBaseOffsets) override;
- /// \brief Dump the overridden layouts.
+ /// Dump the overridden layouts.
void dump();
};
}
diff --git a/include/clang/Frontend/MultiplexConsumer.h b/include/clang/Frontend/MultiplexConsumer.h
index d13565c27bc3..214fefb219cd 100644
--- a/include/clang/Frontend/MultiplexConsumer.h
+++ b/include/clang/Frontend/MultiplexConsumer.h
@@ -17,13 +17,34 @@
#include "clang/Basic/LLVM.h"
#include "clang/Sema/SemaConsumer.h"
+#include "clang/Serialization/ASTDeserializationListener.h"
#include <memory>
#include <vector>
namespace clang {
class MultiplexASTMutationListener;
-class MultiplexASTDeserializationListener;
+
+// This ASTDeserializationListener forwards its notifications to a set of
+// child listeners.
+class MultiplexASTDeserializationListener : public ASTDeserializationListener {
+public:
+ // Does NOT take ownership of the elements in L.
+ MultiplexASTDeserializationListener(
+ const std::vector<ASTDeserializationListener *> &L);
+ void ReaderInitialized(ASTReader *Reader) override;
+ void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override;
+ void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
+ void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+ void DeclRead(serialization::DeclID ID, const Decl *D) override;
+ void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
+ void MacroDefinitionRead(serialization::PreprocessedEntityID,
+ MacroDefinitionRecord *MD) override;
+ void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override;
+
+private:
+ std::vector<ASTDeserializationListener *> Listeners;
+};
// Has a list of ASTConsumers and calls each of them. Owns its children.
class MultiplexConsumer : public SemaConsumer {
diff --git a/include/clang/Frontend/PrecompiledPreamble.h b/include/clang/Frontend/PrecompiledPreamble.h
index 130fe60704a7..6abdbe3a1e1b 100644
--- a/include/clang/Frontend/PrecompiledPreamble.h
+++ b/include/clang/Frontend/PrecompiledPreamble.h
@@ -38,7 +38,7 @@ class CompilerInvocation;
class DeclGroupRef;
class PCHContainerOperations;
-/// \brief Runs lexer to compute suggested preamble bounds.
+/// Runs lexer to compute suggested preamble bounds.
PreambleBounds ComputePreambleBounds(const LangOptions &LangOpts,
llvm::MemoryBuffer *Buffer,
unsigned MaxLines);
@@ -53,7 +53,7 @@ class PrecompiledPreamble {
struct PreambleFileHash;
public:
- /// \brief Try to build PrecompiledPreamble for \p Invocation. See
+ /// Try to build PrecompiledPreamble for \p Invocation. See
/// BuildPreambleError for possible error codes.
///
/// \param Invocation Original CompilerInvocation with options to compile the
@@ -104,14 +104,22 @@ public:
/// 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
/// is accessible.
- /// For in-memory preambles, PrecompiledPreamble instance continues to own
- /// the MemoryBuffer with the Preamble after this method returns. The caller
- /// is reponsible for making sure the PrecompiledPreamble instance outlives
- /// the compiler run and the AST that will be using the PCH.
+ /// Requires that CanReuse() is true.
+ /// For in-memory preambles, PrecompiledPreamble instance continues to own the
+ /// MemoryBuffer with the Preamble after this method returns. The caller is
+ /// 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,
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,
+ llvm::MemoryBuffer *MainFileBuffer) const;
+
private:
PrecompiledPreamble(PCHStorage Storage, std::vector<char> PreambleBytes,
bool PreambleEndsAtStartOfLine,
@@ -222,6 +230,12 @@ 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,
+ 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.
@@ -275,7 +289,6 @@ enum class BuildPreambleError {
PreambleIsEmpty = 1,
CouldntCreateTempFile,
CouldntCreateTargetInfo,
- CouldntCreateVFSOverlay,
BeginSourceFileFailed,
CouldntEmitPCH
};
diff --git a/include/clang/Frontend/SerializedDiagnosticPrinter.h b/include/clang/Frontend/SerializedDiagnosticPrinter.h
index 4c57e9d404f0..dc68c32fb15a 100644
--- a/include/clang/Frontend/SerializedDiagnosticPrinter.h
+++ b/include/clang/Frontend/SerializedDiagnosticPrinter.h
@@ -1,4 +1,4 @@
-//===--- SerializedDiagnosticPrinter.h - Serializer for diagnostics -------===//
+//===--- SerializedDiagnosticPrinter.h - Diagnostics serializer -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -25,11 +25,11 @@ class DiagnosticOptions;
namespace serialized_diags {
-/// \brief Returns a DiagnosticConsumer that serializes diagnostics to
+/// Returns a DiagnosticConsumer that serializes diagnostics to
/// a bitcode file.
///
/// The created DiagnosticConsumer is designed for quick and lightweight
-/// transfer of of diagnostics to the enclosing build system (e.g., an IDE).
+/// transfer of diagnostics to the enclosing build system (e.g., an IDE).
/// This allows wrapper tools for Clang to get diagnostics from Clang
/// (via libclang) without needing to parse Clang's command line output.
///
diff --git a/include/clang/Frontend/SerializedDiagnosticReader.h b/include/clang/Frontend/SerializedDiagnosticReader.h
index 07479844d465..595bdf1f4d7a 100644
--- a/include/clang/Frontend/SerializedDiagnosticReader.h
+++ b/include/clang/Frontend/SerializedDiagnosticReader.h
@@ -1,4 +1,4 @@
-//===--- SerializedDiagnosticReader.h - Reads diagnostics -------*- C++ -*-===//
+//===- SerializedDiagnosticReader.h - Reads diagnostics ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_FRONTEND_SERIALIZED_DIAGNOSTIC_READER_H_
-#define LLVM_CLANG_FRONTEND_SERIALIZED_DIAGNOSTIC_READER_H_
+#ifndef LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H
+#define LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H
#include "clang/Basic/LLVM.h"
#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorOr.h"
+#include <system_error>
namespace clang {
namespace serialized_diags {
@@ -41,90 +43,97 @@ inline std::error_code make_error_code(SDError E) {
return std::error_code(static_cast<int>(E), SDErrorCategory());
}
-/// \brief A location that is represented in the serialized diagnostics.
+/// A location that is represented in the serialized diagnostics.
struct Location {
unsigned FileID;
unsigned Line;
unsigned Col;
unsigned Offset;
+
Location(unsigned FileID, unsigned Line, unsigned Col, unsigned Offset)
: FileID(FileID), Line(Line), Col(Col), Offset(Offset) {}
};
-/// \brief A base class that handles reading serialized diagnostics from a file.
+/// A base class that handles reading serialized diagnostics from a file.
///
/// Subclasses should override the visit* methods with their logic for handling
/// the various constructs that are found in serialized diagnostics.
class SerializedDiagnosticReader {
public:
- SerializedDiagnosticReader() {}
- virtual ~SerializedDiagnosticReader() {}
+ SerializedDiagnosticReader() = default;
+ virtual ~SerializedDiagnosticReader() = default;
- /// \brief Read the diagnostics in \c File
+ /// Read the diagnostics in \c File
std::error_code readDiagnostics(StringRef File);
private:
enum class Cursor;
- /// \brief Read to the next record or block to process.
+ /// Read to the next record or block to process.
llvm::ErrorOr<Cursor> skipUntilRecordOrBlock(llvm::BitstreamCursor &Stream,
unsigned &BlockOrRecordId);
- /// \brief Read a metadata block from \c Stream.
+ /// Read a metadata block from \c Stream.
std::error_code readMetaBlock(llvm::BitstreamCursor &Stream);
- /// \brief Read a diagnostic block from \c Stream.
+ /// Read a diagnostic block from \c Stream.
std::error_code readDiagnosticBlock(llvm::BitstreamCursor &Stream);
protected:
- /// \brief Visit the start of a diagnostic block.
- virtual std::error_code visitStartOfDiagnostic() {
- return std::error_code();
- }
- /// \brief Visit the end of a diagnostic block.
- virtual std::error_code visitEndOfDiagnostic() { return std::error_code(); }
- /// \brief Visit a category. This associates the category \c ID to a \c Name.
+ /// Visit the start of a diagnostic block.
+ virtual std::error_code visitStartOfDiagnostic() { return {}; }
+
+ /// Visit the end of a diagnostic block.
+ virtual std::error_code visitEndOfDiagnostic() { return {}; }
+
+ /// Visit a category. This associates the category \c ID to a \c Name.
virtual std::error_code visitCategoryRecord(unsigned ID, StringRef Name) {
- return std::error_code();
+ return {};
}
- /// \brief Visit a flag. This associates the flag's \c ID to a \c Name.
+
+ /// Visit a flag. This associates the flag's \c ID to a \c Name.
virtual std::error_code visitDiagFlagRecord(unsigned ID, StringRef Name) {
- return std::error_code();
+ return {};
}
- /// \brief Visit a diagnostic.
+
+ /// Visit a diagnostic.
virtual std::error_code
visitDiagnosticRecord(unsigned Severity, const Location &Location,
unsigned Category, unsigned Flag, StringRef Message) {
- return std::error_code();
+ return {};
}
- /// \brief Visit a filename. This associates the file's \c ID to a \c Name.
+
+ /// Visit a filename. This associates the file's \c ID to a \c Name.
virtual std::error_code visitFilenameRecord(unsigned ID, unsigned Size,
unsigned Timestamp,
StringRef Name) {
- return std::error_code();
+ return {};
}
- /// \brief Visit a fixit hint.
+
+ /// Visit a fixit hint.
virtual std::error_code
visitFixitRecord(const Location &Start, const Location &End, StringRef Text) {
- return std::error_code();
+ return {};
}
- /// \brief Visit a source range.
+
+ /// Visit a source range.
virtual std::error_code visitSourceRangeRecord(const Location &Start,
const Location &End) {
- return std::error_code();
- }
- /// \brief Visit the version of the set of diagnostics.
- virtual std::error_code visitVersionRecord(unsigned Version) {
- return std::error_code();
+ return {};
}
+
+ /// Visit the version of the set of diagnostics.
+ virtual std::error_code visitVersionRecord(unsigned Version) { return {}; }
};
-} // end serialized_diags namespace
-} // end clang namespace
+} // namespace serialized_diags
+} // namespace clang
namespace std {
+
template <>
struct is_error_code_enum<clang::serialized_diags::SDError> : std::true_type {};
-}
-#endif
+} // namespace std
+
+#endif // LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H
diff --git a/include/clang/Frontend/SerializedDiagnostics.h b/include/clang/Frontend/SerializedDiagnostics.h
index 2032cd3988db..dacbc678b700 100644
--- a/include/clang/Frontend/SerializedDiagnostics.h
+++ b/include/clang/Frontend/SerializedDiagnostics.h
@@ -16,11 +16,11 @@ namespace clang {
namespace serialized_diags {
enum BlockIDs {
- /// \brief A top-level block which represents any meta data associated
+ /// A top-level block which represents any meta data associated
/// with the diagostics, including versioning of the format.
BLOCK_META = llvm::bitc::FIRST_APPLICATION_BLOCKID,
- /// \brief The this block acts as a container for all the information
+ /// The this block acts as a container for all the information
/// for a specific diagnostic.
BLOCK_DIAG
};
@@ -37,7 +37,7 @@ enum RecordIDs {
RECORD_LAST = RECORD_FIXIT
};
-/// \brief A stable version of DiagnosticIDs::Level.
+/// A stable version of DiagnosticIDs::Level.
///
/// Do not change the order of values in this enum, and please increment the
/// serialized diagnostics version number when you add to it.
@@ -50,7 +50,7 @@ enum Level {
Remark
};
-/// \brief The serialized diagnostics version number.
+/// The serialized diagnostics version number.
enum { VersionNumber = 2 };
} // end serialized_diags namespace
diff --git a/include/clang/Frontend/TextDiagnostic.h b/include/clang/Frontend/TextDiagnostic.h
index 1bbfe9fa02e3..9f33b866a1eb 100644
--- a/include/clang/Frontend/TextDiagnostic.h
+++ b/include/clang/Frontend/TextDiagnostic.h
@@ -20,7 +20,7 @@
namespace clang {
-/// \brief Class to encapsulate the logic for formatting and printing a textual
+/// Class to encapsulate the logic for formatting and printing a textual
/// diagnostic message.
///
/// This class provides an interface for building and emitting a textual
@@ -42,7 +42,7 @@ public:
~TextDiagnostic() override;
- /// \brief Print the diagonstic level to a raw_ostream.
+ /// Print the diagonstic level to a raw_ostream.
///
/// This is a static helper that handles colorizing the level and formatting
/// it into an arbitrary output stream. This is used internally by the
@@ -54,7 +54,7 @@ public:
bool ShowColors,
bool CLFallbackMode = false);
- /// \brief Pretty-print a diagnostic message to a raw_ostream.
+ /// Pretty-print a diagnostic message to a raw_ostream.
///
/// This is a static helper to handle the line wrapping, colorizing, and
/// rendering of a diagnostic message to a particular ostream. It is
diff --git a/include/clang/Frontend/TextDiagnosticBuffer.h b/include/clang/Frontend/TextDiagnosticBuffer.h
index 23f168e2232d..2295f9dbf3bf 100644
--- a/include/clang/Frontend/TextDiagnosticBuffer.h
+++ b/include/clang/Frontend/TextDiagnosticBuffer.h
@@ -1,4 +1,4 @@
-//===--- TextDiagnosticBuffer.h - Buffer Text Diagnostics -------*- C++ -*-===//
+//===- TextDiagnosticBuffer.h - Buffer Text Diagnostics ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,37 +15,41 @@
#define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include <cstddef>
+#include <string>
+#include <utility>
#include <vector>
namespace clang {
-class Preprocessor;
-class SourceManager;
-
class TextDiagnosticBuffer : public DiagnosticConsumer {
public:
- typedef std::vector<std::pair<SourceLocation, std::string> > DiagList;
- typedef DiagList::iterator iterator;
- typedef DiagList::const_iterator const_iterator;
+ using DiagList = std::vector<std::pair<SourceLocation, std::string>>;
+ using iterator = DiagList::iterator;
+ using const_iterator = DiagList::const_iterator;
+
private:
DiagList Errors, Warnings, Remarks, Notes;
+
/// All - All diagnostics in the order in which they were generated. That
/// order likely doesn't correspond to user input order, but it at least
/// keeps notes in the right places. Each pair in the vector is a diagnostic
/// level and an index into the corresponding DiagList above.
std::vector<std::pair<DiagnosticsEngine::Level, size_t>> All;
+
public:
- const_iterator err_begin() const { return Errors.begin(); }
- const_iterator err_end() const { return Errors.end(); }
+ const_iterator err_begin() const { return Errors.begin(); }
+ const_iterator err_end() const { return Errors.end(); }
const_iterator warn_begin() const { return Warnings.begin(); }
- const_iterator warn_end() const { return Warnings.end(); }
+ const_iterator warn_end() const { return Warnings.end(); }
const_iterator remark_begin() const { return Remarks.begin(); }
- const_iterator remark_end() const { return Remarks.end(); }
+ const_iterator remark_end() const { return Remarks.end(); }
const_iterator note_begin() const { return Notes.begin(); }
- const_iterator note_end() const { return Notes.end(); }
+ const_iterator note_end() const { return Notes.end(); }
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info) override;
@@ -55,6 +59,6 @@ public:
void FlushDiagnostics(DiagnosticsEngine &Diags) const;
};
-} // end namspace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h
index 07cee9f8ad8a..3cb4e02edf0d 100644
--- a/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -29,7 +29,7 @@ class TextDiagnosticPrinter : public DiagnosticConsumer {
raw_ostream &OS;
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
- /// \brief Handle to the currently active text diagnostic emitter.
+ /// Handle to the currently active text diagnostic emitter.
std::unique_ptr<TextDiagnostic> TextDiag;
/// A string to prefix to error messages.
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 8ccc31982dab..67912a8dfcdd 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -1,4 +1,4 @@
-//===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===//
+//===- Utils.h - Misc utilities for the front-end ---------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,45 +15,49 @@
#define LLVM_CLANG_FRONTEND_UTILS_H
#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/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Option/OptSpecifier.h"
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <system_error>
#include <utility>
+#include <vector>
namespace llvm {
-class raw_fd_ostream;
+
class Triple;
namespace opt {
+
class ArgList;
-}
-}
+
+} // namespace opt
+
+} // namespace llvm
namespace clang {
-class ASTConsumer;
+
class ASTReader;
class CompilerInstance;
class CompilerInvocation;
-class Decl;
class DependencyOutputOptions;
class DiagnosticsEngine;
-class DiagnosticOptions;
class ExternalSemaSource;
-class FileManager;
+class FrontendOptions;
class HeaderSearch;
class HeaderSearchOptions;
-class IdentifierTable;
class LangOptions;
class PCHContainerReader;
class Preprocessor;
class PreprocessorOptions;
class PreprocessorOutputOptions;
-class SourceManager;
-class Stmt;
-class TargetInfo;
-class FrontendOptions;
/// Apply the header search options to get given HeaderSearch object.
void ApplyHeaderSearchOptions(HeaderSearch &HS,
@@ -68,7 +72,7 @@ void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts,
const FrontendOptions &FEOpts);
/// DoPrintPreprocessedInput - Implement -E mode.
-void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,
+void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
const PreprocessorOutputOptions &Opts);
/// An interface for collecting the dependencies of a compilation. Users should
@@ -78,9 +82,11 @@ void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,
/// interface.
class DependencyCollector {
public:
+ virtual ~DependencyCollector();
+
virtual void attachToPreprocessor(Preprocessor &PP);
virtual void attachToASTReader(ASTReader &R);
- llvm::ArrayRef<std::string> getDependencies() const { return Dependencies; }
+ ArrayRef<std::string> getDependencies() const { return Dependencies; }
/// Called when a new file is seen. Return true if \p Filename should be added
/// to the list of dependencies.
@@ -88,17 +94,19 @@ public:
/// The default implementation ignores <built-in> and system files.
virtual bool sawDependency(StringRef Filename, bool FromModule,
bool IsSystem, bool IsModuleFile, bool IsMissing);
+
/// Called when the end of the main file is reached.
- virtual void finishedMainFile() { }
+ virtual void finishedMainFile() {}
+
/// Return true if system files should be passed to sawDependency().
virtual bool needSystemDependencies() { return false; }
- virtual ~DependencyCollector();
-public: // implementation detail
+ // implementation detail
/// Add a dependency \p Filename if it has not been seen before and
/// sawDependency() returns true.
void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem,
bool IsModuleFile, bool IsMissing);
+
private:
llvm::StringSet<> Seen;
std::vector<std::string> Dependencies;
@@ -110,10 +118,13 @@ private:
/// loaded.
class DependencyFileGenerator {
void *Impl; // Opaque implementation
+
DependencyFileGenerator(void *Impl);
+
public:
static DependencyFileGenerator *CreateAndAttachToPreprocessor(
Preprocessor &PP, const DependencyOutputOptions &Opts);
+
void AttachToASTReader(ASTReader &R);
};
@@ -124,15 +135,20 @@ class ModuleDependencyCollector : public DependencyCollector {
bool HasErrors = false;
llvm::StringSet<> Seen;
vfs::YAMLVFSWriter VFSWriter;
-
llvm::StringMap<std::string> SymLinkMap;
bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result);
- std::error_code copyToRoot(StringRef Src, StringRef Dst = "");
+ std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
+
public:
+ ModuleDependencyCollector(std::string DestDir)
+ : DestDir(std::move(DestDir)) {}
+ ~ModuleDependencyCollector() override { writeFileMap(); }
+
StringRef getDest() { return DestDir; }
bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
- void addFile(StringRef Filename, StringRef FileDst = "");
+ void addFile(StringRef Filename, StringRef FileDst = {});
+
void addFileMapping(StringRef VPath, StringRef RPath) {
VFSWriter.addFileMapping(VPath, RPath);
}
@@ -142,9 +158,6 @@ public:
void writeFileMap();
bool hasErrors() { return HasErrors; }
- ModuleDependencyCollector(std::string DestDir)
- : DestDir(std::move(DestDir)) {}
- ~ModuleDependencyCollector() { writeFileMap(); }
};
/// AttachDependencyGraphGen - Create a dependency graph generator, and attach
@@ -167,7 +180,7 @@ void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
void AttachHeaderIncludeGen(Preprocessor &PP,
const DependencyOutputOptions &DepOpts,
bool ShowAllHeaders = false,
- StringRef OutputPath = "",
+ StringRef OutputPath = {},
bool ShowDepth = true, bool MSStyle = false);
/// Cache tokens for use with PCH. Note that this requires a seekable stream.
@@ -221,6 +234,12 @@ template <typename T> void BuryPointer(std::unique_ptr<T> Ptr) {
BuryPointer(Ptr.release());
}
-} // end namespace clang
+// Frontend timing utils
+
+/// If the user specifies the -ftime-report argument on an Clang command line
+/// then the value of this boolean will be true, otherwise false.
+extern bool FrontendTimesIsEnabled;
+
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_UTILS_H
diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h
index 8d71fb98b0bb..9d985bc4955f 100644
--- a/include/clang/Frontend/VerifyDiagnosticConsumer.h
+++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h
@@ -11,18 +11,24 @@
#define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h"
-#include "llvm/ADT/STLExtras.h"
-#include <climits>
+#include "llvm/ADT/StringRef.h"
+#include <cassert>
+#include <limits>
#include <memory>
+#include <string>
+#include <vector>
namespace clang {
-class DiagnosticsEngine;
-class TextDiagnosticBuffer;
class FileEntry;
+class LangOptions;
+class SourceManager;
+class TextDiagnosticBuffer;
/// VerifyDiagnosticConsumer - Create a diagnostic client which will use
/// markers in the input source to check that all the emitted diagnostics match
@@ -153,7 +159,7 @@ public:
public:
/// Constant representing n or more matches.
- static const unsigned MaxCount = UINT_MAX;
+ static const unsigned MaxCount = std::numeric_limits<unsigned>::max();
SourceLocation DirectiveLoc;
SourceLocation DiagnosticLoc;
@@ -161,7 +167,9 @@ public:
unsigned Min, Max;
bool MatchAnyLine;
- virtual ~Directive() { }
+ Directive(const Directive &) = delete;
+ Directive &operator=(const Directive &) = delete;
+ virtual ~Directive() = default;
// Returns true if directive text is valid.
// Otherwise returns false and populates E.
@@ -173,22 +181,17 @@ public:
protected:
Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)
- : DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc),
- Text(Text), Min(Min), Max(Max), MatchAnyLine(MatchAnyLine) {
- assert(!DirectiveLoc.isInvalid() && "DirectiveLoc is invalid!");
- assert((!DiagnosticLoc.isInvalid() || MatchAnyLine) &&
- "DiagnosticLoc is invalid!");
+ : DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc),
+ Text(Text), Min(Min), Max(Max), MatchAnyLine(MatchAnyLine) {
+ assert(!DirectiveLoc.isInvalid() && "DirectiveLoc is invalid!");
+ assert((!DiagnosticLoc.isInvalid() || MatchAnyLine) &&
+ "DiagnosticLoc is invalid!");
}
-
- private:
- Directive(const Directive &) = delete;
- void operator=(const Directive &) = delete;
};
- typedef std::vector<std::unique_ptr<Directive>> DirectiveList;
+ using DirectiveList = std::vector<std::unique_ptr<Directive>>;
/// ExpectedData - owns directive objects and deletes on destructor.
- ///
struct ExpectedData {
DirectiveList Errors;
DirectiveList Warnings;
@@ -215,14 +218,15 @@ private:
DiagnosticConsumer *PrimaryClient;
std::unique_ptr<DiagnosticConsumer> PrimaryClientOwner;
std::unique_ptr<TextDiagnosticBuffer> Buffer;
- const Preprocessor *CurrentPreprocessor;
- const LangOptions *LangOpts;
- SourceManager *SrcManager;
- unsigned ActiveSourceFiles;
+ const Preprocessor *CurrentPreprocessor = nullptr;
+ const LangOptions *LangOpts = nullptr;
+ SourceManager *SrcManager = nullptr;
+ unsigned ActiveSourceFiles = 0;
DirectiveStatus Status;
ExpectedData ED;
void CheckDiagnostics();
+
void setSourceManager(SourceManager &SM) {
assert((!SrcManager || SrcManager == &SM) && "SourceManager changed!");
SrcManager = &SM;
@@ -231,14 +235,18 @@ private:
// These facilities are used for validation in debug builds.
class UnparsedFileStatus {
llvm::PointerIntPair<const FileEntry *, 1, bool> Data;
+
public:
UnparsedFileStatus(const FileEntry *File, bool FoundDirectives)
- : Data(File, FoundDirectives) {}
+ : Data(File, FoundDirectives) {}
+
const FileEntry *getFile() const { return Data.getPointer(); }
bool foundDirectives() const { return Data.getInt(); }
};
- typedef llvm::DenseMap<FileID, const FileEntry *> ParsedFilesMap;
- typedef llvm::DenseMap<FileID, UnparsedFileStatus> UnparsedFilesMap;
+
+ using ParsedFilesMap = llvm::DenseMap<FileID, const FileEntry *>;
+ using UnparsedFilesMap = llvm::DenseMap<FileID, UnparsedFileStatus>;
+
ParsedFilesMap ParsedFiles;
UnparsedFilesMap UnparsedFiles;
@@ -265,7 +273,7 @@ public:
IsUnparsedNoDirectives
};
- /// \brief Update lists of parsed and unparsed files.
+ /// Update lists of parsed and unparsed files.
void UpdateParsedFileStatus(SourceManager &SM, FileID FID, ParsedStatus PS);
bool HandleComment(Preprocessor &PP, SourceRange Comment) override;
@@ -274,6 +282,6 @@ public:
const Diagnostic &Info) override;
};
-} // end namspace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H