aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp10
-rw-r--r--clang/lib/Frontend/DependencyFile.cpp10
-rw-r--r--clang/lib/Frontend/DependencyGraph.cpp23
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp3
-rw-r--r--clang/lib/Frontend/ModuleDependencyCollector.cpp6
-rw-r--r--clang/lib/Frontend/PrecompiledPreamble.cpp6
-rw-r--r--clang/lib/Frontend/PrintPreprocessedOutput.cpp21
-rw-r--r--clang/lib/Frontend/Rewrite/InclusionRewriter.cpp21
-rw-r--r--clang/lib/Frontend/VerifyDiagnosticConsumer.cpp3
9 files changed, 52 insertions, 51 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 8238779..acb3cb8 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -426,7 +426,7 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags,
// Remap files in the source manager (with other files).
for (const auto &RF : InitOpts.RemappedFiles) {
// Find the file that we're mapping to.
- std::optional<FileEntryRef> ToFile = FileMgr.getOptionalFileRef(RF.second);
+ Optional<FileEntryRef> ToFile = FileMgr.getOptionalFileRef(RF.second);
if (!ToFile) {
Diags.Report(diag::err_fe_remap_missing_to_file) << RF.first << RF.second;
continue;
@@ -1281,8 +1281,8 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
Instance.getFrontendOpts().AllowPCMWithCompilerErrors;
}
-static std::optional<FileEntryRef> getPublicModuleMap(FileEntryRef File,
- FileManager &FileMgr) {
+static Optional<FileEntryRef> getPublicModuleMap(FileEntryRef File,
+ FileManager &FileMgr) {
StringRef Filename = llvm::sys::path::filename(File.getName());
SmallString<128> PublicFilename(File.getDir().getName());
if (Filename == "module_private.map")
@@ -1307,12 +1307,12 @@ static bool compileModule(CompilerInstance &ImportingInstance,
ModuleMap &ModMap
= ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
bool Result;
- if (std::optional<FileEntryRef> ModuleMapFile =
+ if (Optional<FileEntryRef> ModuleMapFile =
ModMap.getContainingModuleMapFile(Module)) {
// Canonicalize compilation to start with the public module map. This is
// vital for submodules declarations in the private module maps to be
// correctly parsed when depending on a top level module in the public one.
- if (std::optional<FileEntryRef> PublicMMFile = getPublicModuleMap(
+ if (Optional<FileEntryRef> PublicMMFile = getPublicModuleMap(
*ModuleMapFile, ImportingInstance.getFileManager()))
ModuleMapFile = PublicMMFile;
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp
index 500c08c..8d712a2 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -10,11 +10,11 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Frontend/Utils.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
#include "clang/Lex/DirectoryLookup.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/PPCallbacks.h"
@@ -24,7 +24,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include <optional>
using namespace clang;
@@ -65,9 +64,8 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ Optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override {
if (!File)
DepCollector.maybeAddDependency(FileName, /*FromModule*/false,
@@ -77,7 +75,7 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
}
void HasInclude(SourceLocation Loc, StringRef SpelledFilename, bool IsAngled,
- std::optional<FileEntryRef> File,
+ Optional<FileEntryRef> File,
SrcMgr::CharacteristicKind FileType) override {
if (!File)
return;
diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp
index ccf34ac..4cbdb3d 100644
--- a/clang/lib/Frontend/DependencyGraph.cpp
+++ b/clang/lib/Frontend/DependencyGraph.cpp
@@ -11,16 +11,15 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Frontend/Utils.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
-#include <optional>
using namespace clang;
namespace DOT = llvm::DOT;
@@ -49,9 +48,8 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ Optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void EndOfMainFile() override {
@@ -68,16 +66,21 @@ void clang::AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
}
void DependencyGraphCallback::InclusionDirective(
- SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ SourceLocation HashLoc,
+ const Token &IncludeTok,
+ StringRef FileName,
+ bool IsAngled,
+ CharSourceRange FilenameRange,
+ Optional<FileEntryRef> File,
+ StringRef SearchPath,
+ StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
if (!File)
return;
SourceManager &SM = PP->getSourceManager();
- std::optional<FileEntryRef> FromFile =
+ Optional<FileEntryRef> FromFile =
SM.getFileEntryRefForID(SM.getFileID(SM.getExpansionLoc(HashLoc)));
if (!FromFile)
return;
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index a3b4080..e97a2dd 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -40,7 +40,6 @@
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
-#include <optional>
#include <system_error>
using namespace clang;
@@ -824,7 +823,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
Dir = *DirOrErr;
SmallVector<std::pair<const FileEntry *, const DirectoryEntry *>, 1> CWD;
CWD.push_back({nullptr, Dir});
- std::optional<FileEntryRef> FE =
+ Optional<FileEntryRef> FE =
HS.LookupFile(FileName, SourceLocation(),
/*Angled*/ Input.getKind().getHeaderUnitKind() ==
InputKind::HeaderUnit_System,
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index 785bff7..7e19ed3 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -19,7 +19,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include <optional>
using namespace clang;
@@ -49,9 +48,8 @@ struct ModuleDependencyPPCallbacks : public PPCallbacks {
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ Optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override {
if (!File)
return;
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp
index 9da3306..e3c3466 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -33,7 +33,6 @@
#include "llvm/Support/VirtualFileSystem.h"
#include <limits>
#include <mutex>
-#include <optional>
#include <utility>
using namespace clang;
@@ -98,9 +97,8 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ Optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override {
// File is None if it wasn't found.
// (We have some false negatives if PP recovered e.g. <foo> -> "foo")
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 8274a2f..d81a11a 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -11,11 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Frontend/Utils.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
-#include "clang/Frontend/Utils.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Pragma.h"
@@ -27,7 +27,6 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
-#include <optional>
using namespace clang;
/// PrintMacroDefinition - Print a macro definition in a form that will be
@@ -147,9 +146,8 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ Optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void Ident(SourceLocation Loc, StringRef str) override;
void PragmaMessage(SourceLocation Loc, StringRef Namespace,
@@ -391,10 +389,15 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
}
void PrintPPOutputPPCallbacks::InclusionDirective(
- SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ SourceLocation HashLoc,
+ const Token &IncludeTok,
+ StringRef FileName,
+ bool IsAngled,
+ CharSourceRange FilenameRange,
+ Optional<FileEntryRef> File,
+ StringRef SearchPath,
+ StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
// In -dI mode, dump #include directives prior to dumping their content or
// interpretation.
diff --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
index 7fa2328..37178d1 100644
--- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -74,9 +74,8 @@ private:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- std::optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ Optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void If(SourceLocation Loc, SourceRange ConditionRange,
ConditionValueKind ConditionValue) override;
@@ -183,12 +182,16 @@ void InclusionRewriter::FileSkipped(const FileEntryRef & /*SkippedFile*/,
/// FileChanged() or FileSkipped() is called after this (or neither is
/// called if this #include results in an error or does not textually include
/// anything).
-void InclusionRewriter::InclusionDirective(
- SourceLocation HashLoc, const Token & /*IncludeTok*/,
- StringRef /*FileName*/, bool /*IsAngled*/,
- CharSourceRange /*FilenameRange*/, std::optional<FileEntryRef> /*File*/,
- StringRef /*SearchPath*/, StringRef /*RelativePath*/,
- const Module *Imported, SrcMgr::CharacteristicKind FileType) {
+void InclusionRewriter::InclusionDirective(SourceLocation HashLoc,
+ const Token &/*IncludeTok*/,
+ StringRef /*FileName*/,
+ bool /*IsAngled*/,
+ CharSourceRange /*FilenameRange*/,
+ Optional<FileEntryRef> /*File*/,
+ StringRef /*SearchPath*/,
+ StringRef /*RelativePath*/,
+ const Module *Imported,
+ SrcMgr::CharacteristicKind FileType){
if (Imported) {
auto P = ModuleIncludes.insert(std::make_pair(HashLoc, Imported));
(void)P;
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index b6e2533..f67dcee 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -40,7 +40,6 @@
#include <cstring>
#include <iterator>
#include <memory>
-#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -542,7 +541,7 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
ExpectedLoc = SourceLocation();
} else {
// Lookup file via Preprocessor, like a #include.
- std::optional<FileEntryRef> File =
+ Optional<FileEntryRef> File =
PP->LookupFile(Pos, Filename, false, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr);
if (!File) {