diff options
author | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2022-12-17 13:57:30 -0800 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2022-12-17 15:24:14 -0800 |
commit | 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d (patch) | |
tree | b16c78031a5bff93437c00aba53b03bc6a166bc0 /clang-tools-extra/clang-tidy | |
parent | 1d43966bc33a55cad1db7758bf4d82526d125db7 (diff) | |
download | llvm-8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.zip llvm-8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.tar.gz llvm-8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.tar.bz2 |
[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional
Diffstat (limited to 'clang-tools-extra/clang-tidy')
12 files changed, 63 insertions, 35 deletions
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 { |