aboutsummaryrefslogtreecommitdiffstats
path: root/include/clang/Frontend
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:49 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:49 +0000
commit2298981669bf3bd63335a4be179bc0f96823a8f4 (patch)
tree1cbe2eb27f030d2d70b80ee5ca3c86bee7326a9f /include/clang/Frontend
parent9a83721404652cea39e9f02ae3e3b5c964602a5c (diff)
downloadsrc-2298981669bf3bd63335a4be179bc0f96823a8f4.tar.gz
src-2298981669bf3bd63335a4be179bc0f96823a8f4.zip
Vendor import of stripped clang trunk r366426 (just before thevendor/clang/clang-trunk-r366426
Notes
Notes: svn path=/vendor/clang/dist/; revision=351280 svn path=/vendor/clang/clang-trunk-r366426/; revision=351281; tag=vendor/clang/clang-trunk-r366426
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h16
-rw-r--r--include/clang/Frontend/ASTUnit.h41
-rw-r--r--include/clang/Frontend/ChainedDiagnosticConsumer.h7
-rw-r--r--include/clang/Frontend/CommandLineSourceLoc.h7
-rw-r--r--include/clang/Frontend/CompilerInstance.h42
-rw-r--r--include/clang/Frontend/CompilerInvocation.h7
-rw-r--r--include/clang/Frontend/DependencyOutputOptions.h7
-rw-r--r--include/clang/Frontend/DiagnosticRenderer.h7
-rw-r--r--include/clang/Frontend/FrontendAction.h11
-rw-r--r--include/clang/Frontend/FrontendActions.h44
-rw-r--r--include/clang/Frontend/FrontendDiagnostic.h7
-rw-r--r--include/clang/Frontend/FrontendOptions.h47
-rw-r--r--include/clang/Frontend/FrontendPluginRegistry.h7
-rw-r--r--include/clang/Frontend/LangStandard.h31
-rw-r--r--include/clang/Frontend/LangStandards.def20
-rw-r--r--include/clang/Frontend/LayoutOverrideSource.h7
-rw-r--r--include/clang/Frontend/LogDiagnosticPrinter.h7
-rw-r--r--include/clang/Frontend/MigratorOptions.h7
-rw-r--r--include/clang/Frontend/MultiplexConsumer.h7
-rw-r--r--include/clang/Frontend/PCHContainerOperations.h7
-rw-r--r--include/clang/Frontend/PrecompiledPreamble.h12
-rw-r--r--include/clang/Frontend/PreprocessorOutputOptions.h7
-rw-r--r--include/clang/Frontend/SerializedDiagnosticPrinter.h9
-rw-r--r--include/clang/Frontend/SerializedDiagnosticReader.h9
-rw-r--r--include/clang/Frontend/SerializedDiagnostics.h9
-rw-r--r--include/clang/Frontend/TextDiagnostic.h7
-rw-r--r--include/clang/Frontend/TextDiagnosticBuffer.h7
-rw-r--r--include/clang/Frontend/TextDiagnosticPrinter.h7
-rw-r--r--include/clang/Frontend/Utils.h63
-rw-r--r--include/clang/Frontend/VerifyDiagnosticConsumer.h51
30 files changed, 304 insertions, 213 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index c2144da054f0..af8c4a517dcd 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -1,9 +1,8 @@
//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -14,6 +13,7 @@
#ifndef LLVM_CLANG_FRONTEND_ASTCONSUMERS_H
#define LLVM_CLANG_FRONTEND_ASTCONSUMERS_H
+#include "clang/AST/ASTDumperUtils.h"
#include "clang/Basic/LLVM.h"
#include <memory>
@@ -36,10 +36,10 @@ std::unique_ptr<ASTConsumer> CreateASTPrinter(std::unique_ptr<raw_ostream> OS,
// 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);
+std::unique_ptr<ASTConsumer>
+CreateASTDumper(std::unique_ptr<raw_ostream> OS, StringRef FilterString,
+ bool DumpDecls, bool Deserialize, bool DumpLookups,
+ ASTDumpOutputFormat Format);
// AST Decl node lister: prints qualified names of all filterable AST Decl
// nodes.
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index d0b532cf2d34..7fb1d2d93380 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -1,9 +1,8 @@
//===- ASTUnit.h - ASTUnit utility ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -72,7 +71,7 @@ class FileManager;
class FrontendAction;
class HeaderSearch;
class InputKind;
-class MemoryBufferCache;
+class InMemoryModuleCache;
class PCHContainerOperations;
class PCHContainerReader;
class Preprocessor;
@@ -83,6 +82,9 @@ class TargetInfo;
/// \brief Enumerates the available scopes for skipping function bodies.
enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
+/// \brief Enumerates the available kinds for capturing diagnostics.
+enum class CaptureDiagsKind { None, All, AllWithoutNonErrorsFromIncludes };
+
/// Utility class for loading a ASTContext from an AST file.
class ASTUnit {
public:
@@ -108,7 +110,7 @@ private:
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
IntrusiveRefCntPtr<FileManager> FileMgr;
IntrusiveRefCntPtr<SourceManager> SourceMgr;
- IntrusiveRefCntPtr<MemoryBufferCache> PCMCache;
+ IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache;
std::unique_ptr<HeaderSearch> HeaderInfo;
IntrusiveRefCntPtr<TargetInfo> Target;
std::shared_ptr<Preprocessor> PP;
@@ -145,7 +147,7 @@ private:
bool OnlyLocalDecls = false;
/// Whether to capture any diagnostics produced.
- bool CaptureDiagnostics = false;
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None;
/// Track whether the main file was loaded from an AST or not.
bool MainFileIsAST;
@@ -206,7 +208,10 @@ 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 = 0;
+ unsigned PreambleRebuildCountdown = 0;
+
+ /// Counter indicating how often the preamble was build in total.
+ unsigned PreambleCounter = 0;
/// Cache pairs "filename - source location"
///
@@ -248,7 +253,7 @@ private:
bool UserFilesAreVolatile : 1;
static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
- ASTUnit &AST, bool CaptureDiagnostics);
+ ASTUnit &AST, CaptureDiagsKind CaptureDiagnostics);
void TranslateStoredDiagnostics(FileManager &FileMgr,
SourceManager &SrcMan,
@@ -575,6 +580,8 @@ public:
mapLocationToPreamble(R.getEnd()));
}
+ unsigned getPreambleCounterForTests() const { return PreambleCounter; }
+
// Retrieve the diagnostics associated with this AST
using stored_diag_iterator = StoredDiagnostic *;
using stored_diag_const_iterator = const StoredDiagnostic *;
@@ -657,8 +664,8 @@ public:
/// Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
static std::unique_ptr<ASTUnit>
create(std::shared_ptr<CompilerInvocation> CI,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool CaptureDiagnostics,
- bool UserFilesAreVolatile);
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+ CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile);
enum WhatToLoad {
/// Load options and the preprocessor state.
@@ -686,7 +693,8 @@ public:
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false,
bool OnlyLocalDecls = false, ArrayRef<RemappedFile> RemappedFiles = None,
- bool CaptureDiagnostics = false, bool AllowPCHWithCompilerErrors = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
+ bool AllowPCHWithCompilerErrors = false,
bool UserFilesAreVolatile = false);
private:
@@ -744,7 +752,8 @@ public:
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
bool Persistent = true, StringRef ResourceFilesPath = StringRef(),
- bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
+ bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
unsigned PrecompilePreambleAfterNParses = 0,
bool CacheCodeCompletionResults = false,
bool IncludeBriefCommentsInCodeCompletion = false,
@@ -769,7 +778,8 @@ public:
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
- bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
+ bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
unsigned PrecompilePreambleAfterNParses = 0,
TranslationUnitKind TUKind = TU_Complete,
bool CacheCodeCompletionResults = false,
@@ -809,7 +819,8 @@ public:
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
- bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
+ bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
ArrayRef<RemappedFile> RemappedFiles = None,
bool RemappedFilesKeepOriginalName = true,
unsigned PrecompilePreambleAfterNParses = 0,
diff --git a/include/clang/Frontend/ChainedDiagnosticConsumer.h b/include/clang/Frontend/ChainedDiagnosticConsumer.h
index 04c6077dc35e..ca284560754f 100644
--- a/include/clang/Frontend/ChainedDiagnosticConsumer.h
+++ b/include/clang/Frontend/ChainedDiagnosticConsumer.h
@@ -1,9 +1,8 @@
//===- ChainedDiagnosticConsumer.h - Chain Diagnostic Clients ---*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h
index 7ae98e079264..e95d100f6a76 100644
--- a/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/include/clang/Frontend/CommandLineSourceLoc.h
@@ -1,10 +1,9 @@
//===--- CommandLineSourceLoc.h - Parsing for source locations-*- C++ -*---===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 83ce079d5e23..eb49c53ff40b 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -1,9 +1,8 @@
//===-- CompilerInstance.h - Clang Compiler Instance ------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -45,7 +44,7 @@ class ExternalASTSource;
class FileEntry;
class FileManager;
class FrontendAction;
-class MemoryBufferCache;
+class InMemoryModuleCache;
class Module;
class Preprocessor;
class Sema;
@@ -83,9 +82,6 @@ class CompilerInstance : public ModuleLoader {
/// Auxiliary Target info.
IntrusiveRefCntPtr<TargetInfo> AuxTarget;
- /// The virtual file system.
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> VirtualFileSystem;
-
/// The file manager.
IntrusiveRefCntPtr<FileManager> FileMgr;
@@ -93,7 +89,7 @@ class CompilerInstance : public ModuleLoader {
IntrusiveRefCntPtr<SourceManager> SourceMgr;
/// The cache of PCM files.
- IntrusiveRefCntPtr<MemoryBufferCache> PCMCache;
+ IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache;
/// The preprocessor.
std::shared_ptr<Preprocessor> PP;
@@ -128,9 +124,6 @@ class CompilerInstance : public ModuleLoader {
/// The module provider.
std::shared_ptr<PCHContainerOperations> ThePCHContainerOperations;
- /// The dependency file generator.
- std::unique_ptr<DependencyFileGenerator> TheDependencyFileGenerator;
-
std::vector<std::shared_ptr<DependencyCollector>> DependencyCollectors;
/// The set of top-level modules that has already been loaded,
@@ -193,7 +186,7 @@ public:
explicit CompilerInstance(
std::shared_ptr<PCHContainerOperations> PCHContainerOps =
std::make_shared<PCHContainerOperations>(),
- MemoryBufferCache *SharedPCMCache = nullptr);
+ InMemoryModuleCache *SharedModuleCache = nullptr);
~CompilerInstance() override;
/// @name High-Level Operations
@@ -383,20 +376,8 @@ public:
/// @name Virtual File System
/// {
- bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; }
-
llvm::vfs::FileSystem &getVirtualFileSystem() const {
- assert(hasVirtualFileSystem() &&
- "Compiler instance has no virtual file system");
- return *VirtualFileSystem;
- }
-
- /// Replace the current virtual file system.
- ///
- /// \note Most clients should use setFileManager, which will implicitly reset
- /// the virtual file system to the one contained in the file manager.
- void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
- VirtualFileSystem = std::move(FS);
+ return getFileManager().getVirtualFileSystem();
}
/// }
@@ -646,7 +627,8 @@ public:
/// Create the file manager and replace any existing one with it.
///
/// \return The new file manager on success, or null on failure.
- FileManager *createFileManager();
+ FileManager *
+ createFileManager(IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// Create the source manager and replace any existing one with it.
void createSourceManager(FileManager &FileMgr);
@@ -672,10 +654,10 @@ public:
/// \return - The new object on success, or null on failure.
static IntrusiveRefCntPtr<ASTReader> createPCHExternalASTSource(
StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
- bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
+ bool AllowPCHWithCompilerErrors, Preprocessor &PP,
+ InMemoryModuleCache &ModuleCache, ASTContext &Context,
const PCHContainerReader &PCHContainerRdr,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
- DependencyFileGenerator *DependencyFile,
ArrayRef<std::shared_ptr<DependencyCollector>> DependencyCollectors,
void *DeserializationListener, bool OwnDeserializationListener,
bool Preamble, bool UseGlobalModuleIndex);
@@ -814,7 +796,7 @@ public:
void setExternalSemaSource(IntrusiveRefCntPtr<ExternalSemaSource> ESS);
- MemoryBufferCache &getPCMCache() const { return *PCMCache; }
+ InMemoryModuleCache &getModuleCache() const { return *ModuleCache; }
};
} // end namespace clang
diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h
index a1874655b040..413134be4cef 100644
--- a/include/clang/Frontend/CompilerInvocation.h
+++ b/include/clang/Frontend/CompilerInvocation.h
@@ -1,9 +1,8 @@
//===- CompilerInvocation.h - Compiler Invocation Helper Data ---*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/DependencyOutputOptions.h b/include/clang/Frontend/DependencyOutputOptions.h
index f419d2643649..7a4f3337936f 100644
--- a/include/clang/Frontend/DependencyOutputOptions.h
+++ b/include/clang/Frontend/DependencyOutputOptions.h
@@ -1,9 +1,8 @@
//===--- DependencyOutputOptions.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/DiagnosticRenderer.h b/include/clang/Frontend/DiagnosticRenderer.h
index 3bbf37946d0b..b939ebe979e7 100644
--- a/include/clang/Frontend/DiagnosticRenderer.h
+++ b/include/clang/Frontend/DiagnosticRenderer.h
@@ -1,9 +1,8 @@
//===- DiagnosticRenderer.h - Diagnostic Pretty-Printing --------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h
index 22314386e060..e994e24cf5af 100644
--- a/include/clang/Frontend/FrontendAction.h
+++ b/include/clang/Frontend/FrontendAction.h
@@ -1,9 +1,8 @@
//===-- FrontendAction.h - Generic Frontend Action Interface ----*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
@@ -24,6 +23,7 @@
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/FrontendOptions.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
#include <memory>
#include <string>
#include <vector>
@@ -230,7 +230,7 @@ public:
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input);
/// Set the source manager's main input file, and run the action.
- bool Execute();
+ llvm::Error Execute();
/// Perform any per-file post processing, deallocate per-file
/// objects, and run statistics and output file cleanup code.
@@ -305,6 +305,7 @@ class WrapperFrontendAction : public FrontendAction {
std::unique_ptr<FrontendAction> WrappedAction;
protected:
+ bool PrepareToExecuteAction(CompilerInstance &CI) override;
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override;
bool BeginInvocation(CompilerInstance &CI) override;
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index eb1cd688429d..6c7bc6046f33 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -1,9 +1,8 @@
//===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -75,12 +74,6 @@ protected:
StringRef InFile) override;
};
-class DeclContextPrintAction : public ASTFrontendAction {
-protected:
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) override;
-};
-
class GeneratePCHAction : public ASTFrontendAction {
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
@@ -126,6 +119,26 @@ protected:
bool hasASTFileSupport() const override { return false; }
};
+class GenerateInterfaceStubAction : public ASTFrontendAction {
+protected:
+ TranslationUnitKind getTranslationUnitKind() override { return TU_Module; }
+
+ bool hasASTFileSupport() const override { return false; }
+};
+
+// Support different interface stub formats this way:
+class GenerateInterfaceYAMLExpV1Action : public GenerateInterfaceStubAction {
+protected:
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override;
+};
+
+class GenerateInterfaceTBEExpV1Action : public GenerateInterfaceStubAction {
+protected:
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override;
+};
+
class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
private:
bool BeginSourceFileAction(CompilerInstance &CI) override;
@@ -247,6 +260,17 @@ protected:
bool usesPreprocessorOnly() const override { return true; }
};
+class PrintDependencyDirectivesSourceMinimizerAction : public FrontendAction {
+protected:
+ void ExecuteAction() override;
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &,
+ StringRef) override {
+ return nullptr;
+ }
+
+ bool usesPreprocessorOnly() const override { return true; }
+};
+
//===----------------------------------------------------------------------===//
// Preprocessor Actions
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/FrontendDiagnostic.h b/include/clang/Frontend/FrontendDiagnostic.h
index 14a28845d45a..f41504d8026d 100644
--- a/include/clang/Frontend/FrontendDiagnostic.h
+++ b/include/clang/Frontend/FrontendDiagnostic.h
@@ -1,9 +1,8 @@
//===--- DiagnosticFrontend.h - Diagnostics for frontend --------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 92191ebd12a6..a0acb1f066f2 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -1,15 +1,15 @@
//===- FrontendOptions.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
#define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
+#include "clang/AST/ASTDumperUtils.h"
#include "clang/Frontend/CommandLineSourceLoc.h"
#include "clang/Serialization/ModuleFileExtension.h"
#include "clang/Sema/CodeCompleteOptions.h"
@@ -88,6 +88,10 @@ enum ActionKind {
/// Generate pre-compiled header.
GeneratePCH,
+ /// Generate Interface Stub Files.
+ GenerateInterfaceYAMLExpV1,
+ GenerateInterfaceTBEExpV1,
+
/// Only execute frontend initialization.
InitOnly,
@@ -128,7 +132,10 @@ enum ActionKind {
MigrateSource,
/// Just lex, no output.
- RunPreprocessorOnly
+ RunPreprocessorOnly,
+
+ /// Print the output of the dependency directives source minimizer.
+ PrintDependencyDirectivesSourceMinimizerOutput
};
} // namespace frontend
@@ -203,7 +210,7 @@ class FrontendInputFile {
/// The input, if it comes from a buffer rather than a file. This object
/// does not own the buffer, and the caller is responsible for ensuring
/// that it outlives any users.
- llvm::MemoryBuffer *Buffer = nullptr;
+ const llvm::MemoryBuffer *Buffer = nullptr;
/// The kind of input, e.g., C source, AST file, LLVM IR.
InputKind Kind;
@@ -215,7 +222,7 @@ public:
FrontendInputFile() = default;
FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false)
: File(File.str()), Kind(Kind), IsSystem(IsSystem) {}
- FrontendInputFile(llvm::MemoryBuffer *Buffer, InputKind Kind,
+ FrontendInputFile(const llvm::MemoryBuffer *Buffer, InputKind Kind,
bool IsSystem = false)
: Buffer(Buffer), Kind(Kind), IsSystem(IsSystem) {}
@@ -232,7 +239,7 @@ public:
return File;
}
- llvm::MemoryBuffer *getBuffer() const {
+ const llvm::MemoryBuffer *getBuffer() const {
assert(isBuffer());
return Buffer;
}
@@ -257,6 +264,12 @@ public:
/// Show timers for individual actions.
unsigned ShowTimers : 1;
+ /// print the supported cpus for the current target
+ unsigned PrintSupportedCPUs : 1;
+
+ /// Output time trace profile.
+ unsigned TimeTrace : 1;
+
/// Show the -version text.
unsigned ShowVersion : 1;
@@ -305,6 +318,9 @@ public:
CodeCompleteOptions CodeCompleteOpts;
+ /// Specifies the output format of the AST.
+ ASTDumpOutputFormat ASTDumpFormat = ADOF_Default;
+
enum {
ARCMT_None,
ARCMT_Check,
@@ -438,13 +454,14 @@ public:
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) {}
+ ShowStats(false), ShowTimers(false), TimeTrace(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.
diff --git a/include/clang/Frontend/FrontendPluginRegistry.h b/include/clang/Frontend/FrontendPluginRegistry.h
index 9a85e89d905d..810578534acb 100644
--- a/include/clang/Frontend/FrontendPluginRegistry.h
+++ b/include/clang/Frontend/FrontendPluginRegistry.h
@@ -1,9 +1,8 @@
//===- FrontendPluginRegistry.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/LangStandard.h b/include/clang/Frontend/LangStandard.h
index 83e452d884b6..244f14c793de 100644
--- a/include/clang/Frontend/LangStandard.h
+++ b/include/clang/Frontend/LangStandard.h
@@ -1,9 +1,8 @@
//===--- LangStandard.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,16 +22,17 @@ enum LangFeatures {
C99 = (1 << 1),
C11 = (1 << 2),
C17 = (1 << 3),
- CPlusPlus = (1 << 4),
- CPlusPlus11 = (1 << 5),
- CPlusPlus14 = (1 << 6),
- CPlusPlus17 = (1 << 7),
- CPlusPlus2a = (1 << 8),
- Digraphs = (1 << 9),
- GNUMode = (1 << 10),
- HexFloat = (1 << 11),
- ImplicitInt = (1 << 12),
- OpenCL = (1 << 13)
+ C2x = (1 << 4),
+ CPlusPlus = (1 << 5),
+ CPlusPlus11 = (1 << 6),
+ CPlusPlus14 = (1 << 7),
+ CPlusPlus17 = (1 << 8),
+ CPlusPlus2a = (1 << 9),
+ Digraphs = (1 << 10),
+ GNUMode = (1 << 11),
+ HexFloat = (1 << 12),
+ ImplicitInt = (1 << 13),
+ OpenCL = (1 << 14)
};
}
@@ -74,6 +74,9 @@ public:
/// isC17 - Language is a superset of C17.
bool isC17() const { return Flags & frontend::C17; }
+ /// isC2x - Language is a superset of C2x.
+ bool isC2x() const { return Flags & frontend::C2x; }
+
/// isCPlusPlus - Language is a C++ variant.
bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Frontend/LangStandards.def
index 0fdd35f32034..0964e9b90a03 100644
--- a/include/clang/Frontend/LangStandards.def
+++ b/include/clang/Frontend/LangStandards.def
@@ -1,9 +1,8 @@
//===-- LangStandards.def - Language Standard Data --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -89,6 +88,14 @@ LANGSTANDARD(gnu17, "gnu17",
LineComment | C99 | C11 | C17 | Digraphs | GNUMode | HexFloat)
LANGSTANDARD_ALIAS(gnu17, "gnu18")
+// C2x modes
+LANGSTANDARD(c2x, "c2x",
+ C, "Working Draft for ISO C2x",
+ LineComment | C99 | C11 | C17 | C2x | Digraphs | HexFloat)
+LANGSTANDARD(gnu2x, "gnu2x",
+ C, "Working Draft for ISO C2x with GNU extensions",
+ LineComment | C99 | C11 | C17 | C2x | Digraphs | GNUMode | HexFloat)
+
// C++ modes
LANGSTANDARD(cxx98, "c++98",
CXX, "ISO C++ 1998 with amendments",
@@ -159,8 +166,9 @@ 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)
+ OpenCL, "C++ for OpenCL",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
+ Digraphs | HexFloat | OpenCL)
LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
diff --git a/include/clang/Frontend/LayoutOverrideSource.h b/include/clang/Frontend/LayoutOverrideSource.h
index 28e3cf005b30..ea1611470a76 100644
--- a/include/clang/Frontend/LayoutOverrideSource.h
+++ b/include/clang/Frontend/LayoutOverrideSource.h
@@ -1,9 +1,8 @@
//===--- LayoutOverrideSource.h --Override Record Layouts -------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/LogDiagnosticPrinter.h b/include/clang/Frontend/LogDiagnosticPrinter.h
index 3286ecf2cdd3..4816275cdc60 100644
--- a/include/clang/Frontend/LogDiagnosticPrinter.h
+++ b/include/clang/Frontend/LogDiagnosticPrinter.h
@@ -1,9 +1,8 @@
//===--- LogDiagnosticPrinter.h - Log Diagnostic Client ---------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/MigratorOptions.h b/include/clang/Frontend/MigratorOptions.h
index 8eb71b13f885..cf50ffcf0c4f 100644
--- a/include/clang/Frontend/MigratorOptions.h
+++ b/include/clang/Frontend/MigratorOptions.h
@@ -1,9 +1,8 @@
//===--- MigratorOptions.h - MigratorOptions Options ------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/MultiplexConsumer.h b/include/clang/Frontend/MultiplexConsumer.h
index 214fefb219cd..ca6ed8310ae9 100644
--- a/include/clang/Frontend/MultiplexConsumer.h
+++ b/include/clang/Frontend/MultiplexConsumer.h
@@ -1,9 +1,8 @@
//===-- MultiplexConsumer.h - AST Consumer for PCH Generation ---*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/PCHContainerOperations.h b/include/clang/Frontend/PCHContainerOperations.h
index 675efbaf56eb..fa977a63f32e 100644
--- a/include/clang/Frontend/PCHContainerOperations.h
+++ b/include/clang/Frontend/PCHContainerOperations.h
@@ -1,9 +1,8 @@
//===--- Frontend/PCHContainerOperations.h - PCH Containers -----*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/PrecompiledPreamble.h b/include/clang/Frontend/PrecompiledPreamble.h
index 6c79895ce1b9..1a8a64951ec4 100644
--- a/include/clang/Frontend/PrecompiledPreamble.h
+++ b/include/clang/Frontend/PrecompiledPreamble.h
@@ -1,9 +1,8 @@
//===--- PrecompiledPreamble.h - Build precompiled preambles ----*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -284,13 +283,16 @@ public:
/// Creates wrapper class for PPCallbacks so we can also process information
/// about includes that are inside of a preamble
virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
+ /// The returned CommentHandler will be added to the preprocessor if not null.
+ virtual CommentHandler *getCommentHandler();
};
enum class BuildPreambleError {
CouldntCreateTempFile = 1,
CouldntCreateTargetInfo,
BeginSourceFileFailed,
- CouldntEmitPCH
+ CouldntEmitPCH,
+ BadInputs
};
class BuildPreambleErrorCategory final : public std::error_category {
diff --git a/include/clang/Frontend/PreprocessorOutputOptions.h b/include/clang/Frontend/PreprocessorOutputOptions.h
index 94afcd06a398..72e5ad1137fb 100644
--- a/include/clang/Frontend/PreprocessorOutputOptions.h
+++ b/include/clang/Frontend/PreprocessorOutputOptions.h
@@ -1,9 +1,8 @@
//===--- PreprocessorOutputOptions.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/SerializedDiagnosticPrinter.h b/include/clang/Frontend/SerializedDiagnosticPrinter.h
index dc68c32fb15a..58954dc6bafa 100644
--- a/include/clang/Frontend/SerializedDiagnosticPrinter.h
+++ b/include/clang/Frontend/SerializedDiagnosticPrinter.h
@@ -1,9 +1,8 @@
//===--- SerializedDiagnosticPrinter.h - Diagnostics serializer -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,7 @@
#include "clang/Basic/LLVM.h"
#include "clang/Frontend/SerializedDiagnostics.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
namespace llvm {
class raw_ostream;
diff --git a/include/clang/Frontend/SerializedDiagnosticReader.h b/include/clang/Frontend/SerializedDiagnosticReader.h
index 595bdf1f4d7a..309e0abb1461 100644
--- a/include/clang/Frontend/SerializedDiagnosticReader.h
+++ b/include/clang/Frontend/SerializedDiagnosticReader.h
@@ -1,9 +1,8 @@
//===- SerializedDiagnosticReader.h - Reads diagnostics ---------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,7 @@
#define LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H
#include "clang/Basic/LLVM.h"
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorOr.h"
#include <system_error>
diff --git a/include/clang/Frontend/SerializedDiagnostics.h b/include/clang/Frontend/SerializedDiagnostics.h
index dacbc678b700..4e67fd13ac5b 100644
--- a/include/clang/Frontend/SerializedDiagnostics.h
+++ b/include/clang/Frontend/SerializedDiagnostics.h
@@ -1,16 +1,15 @@
//===--- SerializedDiagnostics.h - Common data for serialized diagnostics -===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_SERIALIZE_DIAGNOSTICS_H_
#define LLVM_CLANG_FRONTEND_SERIALIZE_DIAGNOSTICS_H_
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
namespace clang {
namespace serialized_diags {
diff --git a/include/clang/Frontend/TextDiagnostic.h b/include/clang/Frontend/TextDiagnostic.h
index 9f33b866a1eb..7cf54839afbe 100644
--- a/include/clang/Frontend/TextDiagnostic.h
+++ b/include/clang/Frontend/TextDiagnostic.h
@@ -1,9 +1,8 @@
//===--- TextDiagnostic.h - Text Diagnostic Pretty-Printing -----*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/TextDiagnosticBuffer.h b/include/clang/Frontend/TextDiagnosticBuffer.h
index 2295f9dbf3bf..5945caf89743 100644
--- a/include/clang/Frontend/TextDiagnosticBuffer.h
+++ b/include/clang/Frontend/TextDiagnosticBuffer.h
@@ -1,9 +1,8 @@
//===- TextDiagnosticBuffer.h - Buffer Text Diagnostics ---------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h
index 3cb4e02edf0d..ba756fa18c30 100644
--- a/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -1,9 +1,8 @@
//===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 89a6b90f293f..74e563218c31 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -1,9 +1,8 @@
//===- Utils.h - Misc utilities for the front-end ---------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -16,6 +15,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
+#include "clang/Frontend/DependencyOutputOptions.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringMap.h"
@@ -47,7 +47,6 @@ namespace clang {
class ASTReader;
class CompilerInstance;
class CompilerInvocation;
-class DependencyOutputOptions;
class DiagnosticsEngine;
class ExternalSemaSource;
class FrontendOptions;
@@ -78,8 +77,7 @@ void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
/// An interface for collecting the dependencies of a compilation. Users should
/// use \c attachToPreprocessor and \c attachToASTReader to get all of the
/// dependencies.
-/// FIXME: Migrate DependencyFileGen and DependencyGraphGen to use this
-/// interface.
+/// FIXME: Migrate DependencyGraphGen to use this interface.
class DependencyCollector {
public:
virtual ~DependencyCollector();
@@ -96,7 +94,7 @@ public:
bool IsSystem, bool IsModuleFile, bool IsMissing);
/// Called when the end of the main file is reached.
- virtual void finishedMainFile() {}
+ virtual void finishedMainFile(DiagnosticsEngine &Diags) {}
/// Return true if system files should be passed to sawDependency().
virtual bool needSystemDependencies() { return false; }
@@ -107,25 +105,48 @@ public:
void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem,
bool IsModuleFile, bool IsMissing);
+protected:
+ /// Return true if the filename was added to the list of dependencies, false
+ /// otherwise.
+ bool addDependency(StringRef Filename);
+
private:
llvm::StringSet<> Seen;
std::vector<std::string> Dependencies;
};
-/// Builds a depdenency file when attached to a Preprocessor (for includes) and
+/// Builds a dependency file when attached to a Preprocessor (for includes) and
/// ASTReader (for module imports), and writes it out at the end of processing
/// a source file. Users should attach to the ast reader whenever a module is
/// loaded.
-class DependencyFileGenerator {
- void *Impl; // Opaque implementation
+class DependencyFileGenerator : public DependencyCollector {
+public:
+ DependencyFileGenerator(const DependencyOutputOptions &Opts);
- DependencyFileGenerator(void *Impl);
+ void attachToPreprocessor(Preprocessor &PP) override;
-public:
- static DependencyFileGenerator *CreateAndAttachToPreprocessor(
- Preprocessor &PP, const DependencyOutputOptions &Opts);
+ void finishedMainFile(DiagnosticsEngine &Diags) override;
- void AttachToASTReader(ASTReader &R);
+ bool needSystemDependencies() final override { return IncludeSystemHeaders; }
+
+ bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem,
+ bool IsModuleFile, bool IsMissing) final override;
+
+protected:
+ void outputDependencyFile(llvm::raw_ostream &OS);
+
+private:
+ void outputDependencyFile(DiagnosticsEngine &Diags);
+
+ std::string OutputFile;
+ std::vector<std::string> Targets;
+ bool IncludeSystemHeaders;
+ bool PhonyTarget;
+ bool AddMissingHeaderDeps;
+ bool SeenMissingHeader;
+ bool IncludeModuleFiles;
+ DependencyOutputFormat OutputFormat;
+ unsigned InputFileIndex;
};
/// Collects the dependencies for imported modules into a directory. Users
@@ -146,18 +167,18 @@ public:
~ModuleDependencyCollector() override { writeFileMap(); }
StringRef getDest() { return DestDir; }
- bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
- void addFile(StringRef Filename, StringRef FileDst = {});
+ virtual bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
+ virtual void addFile(StringRef Filename, StringRef FileDst = {});
- void addFileMapping(StringRef VPath, StringRef RPath) {
+ virtual void addFileMapping(StringRef VPath, StringRef RPath) {
VFSWriter.addFileMapping(VPath, RPath);
}
void attachToPreprocessor(Preprocessor &PP) override;
void attachToASTReader(ASTReader &R) override;
- void writeFileMap();
- bool hasErrors() { return HasErrors; }
+ virtual void writeFileMap();
+ virtual bool hasErrors() { return HasErrors; }
};
/// AttachDependencyGraphGen - Create a dependency graph generator, and attach
diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h
index f36970f1eb39..965a14410832 100644
--- a/include/clang/Frontend/VerifyDiagnosticConsumer.h
+++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h
@@ -1,9 +1,8 @@
//===- VerifyDiagnosticConsumer.h - Verifying Diagnostic Client -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,7 +33,33 @@ class TextDiagnosticBuffer;
/// markers in the input source to check that all the emitted diagnostics match
/// those expected.
///
-/// USING THE DIAGNOSTIC CHECKER:
+/// INVOKING THE DIAGNOSTIC CHECKER:
+///
+/// VerifyDiagnosticConsumer is typically invoked via the "-verify" option to
+/// "clang -cc1". "-verify" is equivalent to "-verify=expected", so all
+/// diagnostics are typically specified with the prefix "expected". For
+/// example:
+///
+/// \code
+/// int A = B; // expected-error {{use of undeclared identifier 'B'}}
+/// \endcode
+///
+/// Custom prefixes can be specified as a comma-separated sequence. Each
+/// prefix must start with a letter and contain only alphanumeric characters,
+/// hyphens, and underscores. For example, given just "-verify=foo,bar",
+/// the above diagnostic would be ignored, but the following diagnostics would
+/// be recognized:
+///
+/// \code
+/// int A = B; // foo-error {{use of undeclared identifier 'B'}}
+/// int C = D; // bar-error {{use of undeclared identifier 'D'}}
+/// \endcode
+///
+/// Multiple occurrences accumulate prefixes. For example,
+/// "-verify -verify=foo,bar -verify=baz" is equivalent to
+/// "-verify=expected,foo,bar,baz".
+///
+/// SPECIFYING DIAGNOSTICS:
///
/// Indicating that a line expects an error or a warning is simple. Put a
/// comment on the line that has the diagnostic, use:
@@ -82,6 +107,19 @@ class TextDiagnosticBuffer;
/// the included file is, for example, a system header where the actual line
/// number may change and is not critical).
///
+/// As an alternative to specifying a fixed line number, the location of a
+/// diagnostic can instead be indicated by a marker of the form "#<marker>".
+/// Markers are specified by including them in a comment, and then referenced
+/// by appending the marker to the diagnostic with "@#<marker>":
+///
+/// \code
+/// #warning some text // #1
+/// // expected-warning@#1 {{some text}}
+/// \endcode
+///
+/// The name of a marker used in a directive must be unique within the
+/// compilation.
+///
/// The simple syntax above allows each specification to match exactly one
/// error. You can use the extended syntax to customize this. The extended
/// syntax is "expected-<type> <n> {{diag text}}", where \<type> is one of
@@ -213,11 +251,14 @@ public:
HasOtherExpectedDirectives
};
+ class MarkerTracker;
+
private:
DiagnosticsEngine &Diags;
DiagnosticConsumer *PrimaryClient;
std::unique_ptr<DiagnosticConsumer> PrimaryClientOwner;
std::unique_ptr<TextDiagnosticBuffer> Buffer;
+ std::unique_ptr<MarkerTracker> Markers;
const Preprocessor *CurrentPreprocessor = nullptr;
const LangOptions *LangOpts = nullptr;
SourceManager *SrcManager = nullptr;