aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@quicinc.com>2022-12-17 13:57:30 -0800
committerKrzysztof Parzyszek <kparzysz@quicinc.com>2022-12-17 15:24:14 -0800
commit8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d (patch)
treeb16c78031a5bff93437c00aba53b03bc6a166bc0 /clang-tools-extra
parent1d43966bc33a55cad1db7758bf4d82526d125db7 (diff)
downloadllvm-8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.zip
llvm-8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.tar.gz
llvm-8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.tar.bz2
[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clang-move/Move.cpp5
-rw-r--r--clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h6
-rw-r--r--clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp13
-rw-r--r--clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp11
-rw-r--r--clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp11
-rw-r--r--clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp11
-rw-r--r--clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h6
-rw-r--r--clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp11
-rw-r--r--clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp3
-rw-r--r--clang-tools-extra/clangd/Headers.cpp3
-rw-r--r--clang-tools-extra/clangd/ParsedAST.cpp6
-rw-r--r--clang-tools-extra/clangd/index/IndexAction.cpp5
-rw-r--r--clang-tools-extra/clangd/unittests/ParsedASTTests.cpp3
-rw-r--r--clang-tools-extra/include-cleaner/lib/Record.cpp5
-rw-r--r--clang-tools-extra/modularize/CoverageChecker.cpp8
-rw-r--r--clang-tools-extra/modularize/PreprocessorTracker.cpp5
-rw-r--r--clang-tools-extra/pp-trace/PPCallbacksTracker.cpp10
-rw-r--r--clang-tools-extra/pp-trace/PPCallbacksTracker.h7
22 files changed, 98 insertions, 57 deletions
diff --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp
index 9e44fe1..8fe1a99 100644
--- a/clang-tools-extra/clang-move/Move.cpp
+++ b/clang-tools-extra/clang-move/Move.cpp
@@ -18,6 +18,7 @@
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
+#include <optional>
#define DEBUG_TYPE "clang-move"
@@ -131,8 +132,8 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token & /*IncludeTok*/,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> /*File*/, StringRef SearchPath,
- StringRef /*RelativePath*/,
+ std::optional<FileEntryRef> /*File*/,
+ StringRef SearchPath, StringRef /*RelativePath*/,
const Module * /*Imported*/,
SrcMgr::CharacteristicKind /*FileType*/) override {
if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc)))
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index f88e24c..62a1700 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -12,6 +12,7 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/ASTReader.h"
+#include <optional>
#define DEBUG_TYPE "clang-tidy"
@@ -162,7 +163,7 @@ void ExpandModularHeadersPPCallbacks::FileChanged(
void ExpandModularHeadersPPCallbacks::InclusionDirective(
SourceLocation DirectiveLoc, const Token &IncludeToken,
StringRef IncludedFilename, bool IsAngled, CharSourceRange FilenameRange,
- Optional<FileEntryRef> IncludedFile, StringRef SearchPath,
+ std::optional<FileEntryRef> IncludedFile, StringRef SearchPath,
StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
if (Imported) {
@@ -224,7 +225,8 @@ void ExpandModularHeadersPPCallbacks::PragmaDiagnostic(SourceLocation Loc,
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::HasInclude(SourceLocation Loc, StringRef,
- bool, Optional<FileEntryRef>,
+ bool,
+ std::optional<FileEntryRef>,
SrcMgr::CharacteristicKind) {
parseToLocation(Loc);
}
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
index 29f0605..7e616dc 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
@@ -12,6 +12,7 @@
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseSet.h"
+#include <optional>
namespace llvm {
namespace vfs {
@@ -69,7 +70,7 @@ private:
void InclusionDirective(SourceLocation DirectiveLoc,
const Token &IncludeToken, StringRef IncludedFilename,
bool IsAngled, CharSourceRange FilenameRange,
- Optional<FileEntryRef> IncludedFile,
+ std::optional<FileEntryRef> IncludedFile,
StringRef SearchPath, StringRef RelativePath,
const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
@@ -91,7 +92,8 @@ private:
void PragmaDiagnosticPop(SourceLocation Loc, StringRef) override;
void PragmaDiagnostic(SourceLocation Loc, StringRef, diag::Severity,
StringRef) override;
- void HasInclude(SourceLocation Loc, StringRef, bool, Optional<FileEntryRef> ,
+ void HasInclude(SourceLocation Loc, StringRef, bool,
+ std::optional<FileEntryRef>,
SrcMgr::CharacteristicKind) override;
void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *,
SourceLocation StateLoc, unsigned) override;
diff --git a/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp b/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
index c51fd53..6a8214c 100644
--- a/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
@@ -10,6 +10,7 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
+#include <optional>
#include <string>
#include <vector>
@@ -30,8 +31,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FileNameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void EndOfMainFile() override;
@@ -62,7 +64,7 @@ void KernelNameRestrictionCheck::registerPPCallbacks(const SourceManager &SM,
void KernelNameRestrictionPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &, StringRef FileName, bool,
- CharSourceRange, Optional<FileEntryRef>, StringRef, StringRef,
+ CharSourceRange, std::optional<FileEntryRef>, StringRef, StringRef,
const Module *, SrcMgr::CharacteristicKind) {
IncludeDirective ID = {HashLoc, FileName};
IncludeDirectives.push_back(std::move(ID));
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
index b8fbc6e..08d2cf1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -9,6 +9,7 @@
#include "SuspiciousIncludeCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/Lex/Preprocessor.h"
+#include <optional>
namespace clang {
namespace tidy {
@@ -25,8 +26,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
private:
@@ -72,8 +74,9 @@ void SuspiciousIncludeCheck::registerPPCallbacks(
void SuspiciousIncludePPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import)
return;
@@ -93,7 +96,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective(
llvm::sys::path::replace_extension(GuessedFileName,
(HFE.size() ? "." : "") + HFE);
- Optional<FileEntryRef> File =
+ std::optional<FileEntryRef> File =
PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
if (File) {
diff --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index f701bd1..617dfb6 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/STLExtras.h"
#include <map>
+#include <optional>
namespace clang {
namespace tidy {
@@ -28,8 +29,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void EndOfMainFile() override;
@@ -82,8 +84,9 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
void IncludeOrderPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
// We recognize the first include as a special main module header and want
// to leave it in the top position.
diff --git a/clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
index 62379f1..97b5bae 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
@@ -12,6 +12,7 @@
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/Preprocessor.h"
+#include <optional>
// FixItHint - Hint to check documentation script to mark this check as
// providing a FixIt.
@@ -34,8 +35,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
private:
@@ -46,8 +48,9 @@ private:
void RestrictedIncludesPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
// Compiler provided headers are allowed (e.g stddef.h).
if (SrcMgr::isSystem(FileType) && SearchPath == CompilerIncudeDir)
diff --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 64e70ad..ea3e84d 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/StringSet.h"
#include <algorithm>
+#include <optional>
#include <vector>
using IncludeMarker =
@@ -33,8 +34,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
private:
@@ -179,8 +181,9 @@ IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(
void IncludeModernizePPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
// If we don't want to warn for non-main file reports and this is one, skip
diff --git a/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
index 1c196a9..32489e0 100644
--- a/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
#include <cassert>
#include <cctype>
+#include <optional>
#include <string>
namespace clang {
@@ -119,8 +120,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override {
clearCurrentEnum(HashLoc);
}
diff --git a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
index 7faf7cc..c914d9c 100644
--- a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Path.h"
#include <cstring>
+#include <optional>
namespace clang {
namespace tidy {
@@ -22,8 +23,9 @@ namespace portability {
void RestrictedIncludesPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
if (!Check.contains(FileName) && SrcMgr::isSystem(FileType)) {
SmallString<256> FullPath;
diff --git a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
index 2919b06..165aadb 100644
--- a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
+++ b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
@@ -12,6 +12,7 @@
#include "../ClangTidyCheck.h"
#include "../GlobList.h"
#include "clang/Lex/PPCallbacks.h"
+#include <optional>
namespace clang {
namespace tidy {
@@ -51,8 +52,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void EndOfMainFile() override;
diff --git a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
index 22a4e4e..84b97d1 100644
--- a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
@@ -12,6 +12,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <memory>
+#include <optional>
namespace clang {
namespace tidy {
@@ -48,8 +49,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
void MacroDefined(const Token &MacroNameTok,
@@ -77,8 +79,9 @@ void DuplicateIncludeCallbacks::FileChanged(SourceLocation Loc,
void DuplicateIncludeCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, StringRef SearchPath,
+ StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
if (llvm::is_contained(Files.back(), FileName)) {
// We want to delete the entire line, so make sure that [Start,End] covers
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
index 08bbe9d..f497f79 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -10,6 +10,7 @@
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/Token.h"
+#include <optional>
namespace clang {
namespace tidy {
@@ -24,7 +25,7 @@ public:
void InclusionDirective(SourceLocation HashLocation,
const Token &IncludeToken, StringRef FileNameRef,
bool IsAngled, CharSourceRange FileNameRange,
- Optional<FileEntryRef> /*IncludedFile*/,
+ std::optional<FileEntryRef> /*IncludedFile*/,
StringRef /*SearchPath*/, StringRef /*RelativePath*/,
const Module * /*ImportedModule*/,
SrcMgr::CharacteristicKind /*FileType*/) override {
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index 4314ef1..a4647b3 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Path.h"
#include <cstring>
+#include <optional>
namespace clang {
namespace clangd {
@@ -35,7 +36,7 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
llvm::StringRef FileName, bool IsAngled,
CharSourceRange /*FilenameRange*/,
- Optional<FileEntryRef> File,
+ std::optional<FileEntryRef> File,
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module * /*Imported*/,
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index 4e99365..edb46cf 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -50,6 +50,7 @@
#include "llvm/ADT/StringRef.h"
#include <algorithm>
#include <memory>
+#include <optional>
#include <vector>
// Force the linker to link in Clang-tidy modules.
@@ -171,9 +172,10 @@ private:
void replay() {
for (const auto &Inc : Includes) {
- llvm::Optional<FileEntryRef> File;
+ std::optional<FileEntryRef> File;
if (Inc.Resolved != "")
- File = expectedToOptional(SM.getFileManager().getFileRef(Inc.Resolved));
+ File =
+ expectedToStdOptional(SM.getFileManager().getFileRef(Inc.Resolved));
// Re-lex the #include directive to find its interesting parts.
auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
diff --git a/clang-tools-extra/clangd/index/IndexAction.cpp b/clang-tools-extra/clangd/index/IndexAction.cpp
index aaba2c9..9041c79 100644
--- a/clang-tools-extra/clangd/index/IndexAction.cpp
+++ b/clang-tools-extra/clangd/index/IndexAction.cpp
@@ -22,13 +22,14 @@
#include <cstddef>
#include <functional>
#include <memory>
+#include <optional>
#include <utility>
namespace clang {
namespace clangd {
namespace {
-llvm::Optional<std::string> toURI(Optional<FileEntryRef> File) {
+std::optional<std::string> toURI(std::optional<FileEntryRef> File) {
if (!File)
return std::nullopt;
auto AbsolutePath = File->getFileEntry().tryGetRealPathName();
@@ -85,7 +86,7 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
llvm::StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File,
+ std::optional<FileEntryRef> File,
llvm::StringRef SearchPath,
llvm::StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override {
diff --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
index 8167413..52f7ded 100644
--- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -37,6 +37,7 @@
#include "gmock/gmock-matchers.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include <optional>
namespace clang {
namespace clangd {
@@ -381,7 +382,7 @@ TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef>, StringRef, StringRef,
+ std::optional<FileEntryRef>, StringRef, StringRef,
const clang::Module *,
SrcMgr::CharacteristicKind) override {
Includes.emplace_back(SM, HashLoc, IncludeTok, FileName, IsAngled,
diff --git a/clang-tools-extra/include-cleaner/lib/Record.cpp b/clang-tools-extra/include-cleaner/lib/Record.cpp
index e16be12..efdacc7 100644
--- a/clang-tools-extra/include-cleaner/lib/Record.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -17,6 +17,7 @@
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include <optional>
namespace clang::include_cleaner {
namespace {
@@ -35,7 +36,7 @@ public:
void InclusionDirective(SourceLocation Hash, const Token &IncludeTok,
StringRef SpelledFilename, bool IsAngled,
CharSourceRange FilenameRange,
- llvm::Optional<FileEntryRef> File,
+ std::optional<FileEntryRef> File,
StringRef SearchPath, StringRef RelativePath,
const Module *, SrcMgr::CharacteristicKind) override {
if (!Active)
@@ -180,7 +181,7 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
llvm::StringRef FileName, bool IsAngled,
CharSourceRange /*FilenameRange*/,
- Optional<FileEntryRef> File,
+ std::optional<FileEntryRef> File,
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module * /*Imported*/,
diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp
index 610fb59..d1c0cf8 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -50,9 +50,9 @@
//
//===----------------------------------------------------------------------===//
+#include "CoverageChecker.h"
#include "ModularizeUtilities.h"
#include "clang/AST/ASTConsumer.h"
-#include "CoverageChecker.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
@@ -69,6 +69,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
+#include <optional>
using namespace Modularize;
using namespace clang;
@@ -89,8 +90,9 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ std::optional<FileEntryRef> File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported,
SrcMgr::CharacteristicKind FileType) override {
Checker.collectUmbrellaHeaderHeader(File->getName());
}
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp
index 171a938..f697288 100644
--- a/clang-tools-extra/modularize/PreprocessorTracker.cpp
+++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp
@@ -251,6 +251,7 @@
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/raw_ostream.h"
+#include <optional>
namespace Modularize {
@@ -734,7 +735,7 @@ public:
const clang::Token &IncludeTok,
llvm::StringRef FileName, bool IsAngled,
clang::CharSourceRange FilenameRange,
- llvm::Optional<clang::FileEntryRef> File,
+ std::optional<clang::FileEntryRef> File,
llvm::StringRef SearchPath,
llvm::StringRef RelativePath,
const clang::Module *Imported,
@@ -1278,7 +1279,7 @@ void PreprocessorCallbacks::InclusionDirective(
clang::SourceLocation HashLoc, const clang::Token &IncludeTok,
llvm::StringRef FileName, bool IsAngled,
clang::CharSourceRange FilenameRange,
- llvm::Optional<clang::FileEntryRef> File, llvm::StringRef SearchPath,
+ std::optional<clang::FileEntryRef> File, llvm::StringRef SearchPath,
llvm::StringRef RelativePath, const clang::Module *Imported,
clang::SrcMgr::CharacteristicKind FileType) {
int DirectiveLine, DirectiveColumn;
diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
index c143455..1f2eeda 100644
--- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
+++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
@@ -17,6 +17,7 @@
#include "clang/Basic/FileManager.h"
#include "clang/Lex/MacroArgs.h"
#include "llvm/Support/raw_ostream.h"
+#include <optional>
namespace clang {
namespace pp_trace {
@@ -133,9 +134,10 @@ void PPCallbacksTracker::FileSkipped(const FileEntryRef &SkippedFile,
// of whether the inclusion will actually result in an inclusion.
void PPCallbacksTracker::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName,
- bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
- llvm::StringRef SearchPath, llvm::StringRef RelativePath,
- const Module *Imported, SrcMgr::CharacteristicKind FileType) {
+ bool IsAngled, CharSourceRange FilenameRange,
+ std::optional<FileEntryRef> File, llvm::StringRef SearchPath,
+ llvm::StringRef RelativePath, const Module *Imported,
+ SrcMgr::CharacteristicKind FileType) {
beginCallback("InclusionDirective");
appendArgument("HashLoc", HashLoc);
appendArgument("IncludeTok", IncludeTok);
@@ -486,7 +488,7 @@ void PPCallbacksTracker::appendArgument(const char *Name, FileID Value) {
// Append a FileEntry argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- Optional<FileEntryRef> Value) {
+ std::optional<FileEntryRef> Value) {
if (!Value) {
appendArgument(Name, "(null)");
return;
diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.h b/clang-tools-extra/pp-trace/PPCallbacksTracker.h
index 8640146..c494556 100644
--- a/clang-tools-extra/pp-trace/PPCallbacksTracker.h
+++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.h
@@ -21,14 +21,15 @@
#ifndef PPTRACE_PPCALLBACKSTRACKER_H
#define PPTRACE_PPCALLBACKSTRACKER_H
+#include "clang/Basic/SourceManager.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
-#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/GlobPattern.h"
+#include <optional>
#include <string>
#include <vector>
@@ -94,7 +95,7 @@ public:
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
llvm::StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
- Optional<FileEntryRef> File,
+ std::optional<FileEntryRef> File,
llvm::StringRef SearchPath,
llvm::StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;
@@ -179,7 +180,7 @@ public:
void appendArgument(const char *Name, FileID Value);
/// Append a FileEntryRef argument to the top trace item.
- void appendArgument(const char *Name, Optional<FileEntryRef> Value);
+ void appendArgument(const char *Name, std::optional<FileEntryRef> Value);
void appendArgument(const char *Name, FileEntryRef Value);
/// Append a SourceLocation argument to the top trace item.