diff options
author | Kazu Hirata <kazu@google.com> | 2024-12-11 21:13:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-11 21:13:13 -0800 |
commit | 02dd73a5d585af9a950baa38855305fdb17c76af (patch) | |
tree | be0b068454fa4a084537d0278cb72250d9c79e25 | |
parent | 48ed91871dccf12dbe27e96b457ccee373c68a1e (diff) | |
download | llvm-02dd73a5d585af9a950baa38855305fdb17c76af.zip llvm-02dd73a5d585af9a950baa38855305fdb17c76af.tar.gz llvm-02dd73a5d585af9a950baa38855305fdb17c76af.tar.bz2 |
[clang] Migrate away from PointerUnion::{is,get} (NFC) (#119654)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
-rw-r--r-- | clang/include/clang/Lex/PreprocessingRecord.h | 4 | ||||
-rw-r--r-- | clang/include/clang/Lex/Preprocessor.h | 6 | ||||
-rw-r--r-- | clang/lib/Analysis/PathDiagnostic.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Index/FileIndexRecord.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Index/IndexDecl.cpp | 4 | ||||
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 6 | ||||
-rw-r--r-- | clang/tools/libclang/CIndexCXX.cpp | 8 | ||||
-rw-r--r-- | clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 4 |
9 files changed, 21 insertions, 21 deletions
diff --git a/clang/include/clang/Lex/PreprocessingRecord.h b/clang/include/clang/Lex/PreprocessingRecord.h index 437d8e4c..7886aef 100644 --- a/clang/include/clang/Lex/PreprocessingRecord.h +++ b/clang/include/clang/Lex/PreprocessingRecord.h @@ -180,13 +180,13 @@ class Token; } /// True if it is a builtin macro. - bool isBuiltinMacro() const { return NameOrDef.is<IdentifierInfo *>(); } + bool isBuiltinMacro() const { return isa<IdentifierInfo *>(NameOrDef); } /// The name of the macro being expanded. const IdentifierInfo *getName() const { if (MacroDefinitionRecord *Def = getDefinition()) return Def->getName(); - return NameOrDef.get<IdentifierInfo *>(); + return cast<IdentifierInfo *>(NameOrDef); } /// The definition of the macro being expanded. May return null if diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 3312d4e..3d223c3 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -859,7 +859,7 @@ private: auto *Info = State.dyn_cast<ModuleMacroInfo*>(); if (!Info) { Info = new (PP.getPreprocessorAllocator()) - ModuleMacroInfo(State.get<MacroDirective *>()); + ModuleMacroInfo(cast<MacroDirective *>(State)); State = Info; } @@ -892,7 +892,7 @@ private: MacroDirective *getLatest() const { if (auto *Info = State.dyn_cast<ModuleMacroInfo*>()) return Info->MD; - return State.get<MacroDirective*>(); + return cast<MacroDirective *>(State); } void setLatest(MacroDirective *MD) { @@ -945,7 +945,7 @@ private: if (Overrides.empty()) return; Info = new (PP.getPreprocessorAllocator()) - ModuleMacroInfo(State.get<MacroDirective *>()); + ModuleMacroInfo(cast<MacroDirective *>(State)); State = Info; } Info->OverriddenMacros.clear(); diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp index 35472e7..5b14d13 100644 --- a/clang/lib/Analysis/PathDiagnostic.cpp +++ b/clang/lib/Analysis/PathDiagnostic.cpp @@ -484,10 +484,10 @@ SourceLocation PathDiagnosticLocation::getValidSourceLocation( // source code, so find an enclosing statement and use its location. if (!L.isValid()) { AnalysisDeclContext *ADC; - if (LAC.is<const LocationContext*>()) - ADC = LAC.get<const LocationContext*>()->getAnalysisDeclContext(); + if (auto *LC = dyn_cast<const LocationContext *>(LAC)) + ADC = LC->getAnalysisDeclContext(); else - ADC = LAC.get<AnalysisDeclContext*>(); + ADC = cast<AnalysisDeclContext *>(LAC); ParentMap &PM = ADC->getParentMap(); diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 2876c29..f44b5e4 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -398,7 +398,7 @@ FileEntryRef FileManager::getVirtualFileRef(StringRef Filename, off_t Size, {Filename, std::errc::no_such_file_or_directory}).first; if (NamedFileEnt.second) { FileEntryRef::MapValue Value = *NamedFileEnt.second; - if (LLVM_LIKELY(Value.V.is<FileEntry *>())) + if (LLVM_LIKELY(isa<FileEntry *>(Value.V))) return FileEntryRef(NamedFileEnt); return FileEntryRef(*Value.V.get<const FileEntryRef::MapEntry *>()); } diff --git a/clang/lib/Index/FileIndexRecord.cpp b/clang/lib/Index/FileIndexRecord.cpp index f3a5e6b..449c336 100644 --- a/clang/lib/Index/FileIndexRecord.cpp +++ b/clang/lib/Index/FileIndexRecord.cpp @@ -65,7 +65,7 @@ void FileIndexRecord::print(llvm::raw_ostream &OS, SourceManager &SM) const { OS << ' ' << ND->getDeclName(); } } else { - const auto *MI = DclInfo.DeclOrMacro.get<const MacroInfo *>(); + const auto *MI = cast<const MacroInfo *>(DclInfo.DeclOrMacro); SourceLocation Loc = SM.getFileLoc(MI->getDefinitionLoc()); PresumedLoc PLoc = SM.getPresumedLoc(Loc); OS << llvm::sys::path::filename(PLoc.getFilename()) << ':' diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index a7fa6c5..19cff03 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -665,9 +665,9 @@ public: ClassTemplatePartialSpecializationDecl *> Template = D->getSpecializedTemplateOrPartial(); const Decl *SpecializationOf = - Template.is<ClassTemplateDecl *>() + isa<ClassTemplateDecl *>(Template) ? (Decl *)Template.get<ClassTemplateDecl *>() - : Template.get<ClassTemplatePartialSpecializationDecl *>(); + : cast<ClassTemplatePartialSpecializationDecl *>(Template); if (!D->isThisDeclarationADefinition()) IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D); IndexCtx.indexTagDecl( diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index def4524..221f419 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -5270,7 +5270,7 @@ CXString clang_getCursorSpelling(CXCursor C) { if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>()) return cxstring::createDup(E->getName().getAsString()); OverloadedTemplateStorage *Ovl = - Storage.get<OverloadedTemplateStorage *>(); + cast<OverloadedTemplateStorage *>(Storage); if (Ovl->size() == 0) return cxstring::createEmpty(); return cxstring::createDup((*Ovl->begin())->getNameAsString()); @@ -7309,7 +7309,7 @@ unsigned clang_getNumOverloadedDecls(CXCursor C) { Storage.dyn_cast<OverloadedTemplateStorage *>()) return S->size(); - const Decl *D = Storage.get<const Decl *>(); + const Decl *D = cast<const Decl *>(Storage); if (const UsingDecl *Using = dyn_cast<UsingDecl>(D)) return Using->shadow_size(); @@ -7332,7 +7332,7 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) { Storage.dyn_cast<OverloadedTemplateStorage *>()) return MakeCXCursor(S->begin()[index], TU); - const Decl *D = Storage.get<const Decl *>(); + const Decl *D = cast<const Decl *>(Storage); if (const UsingDecl *Using = dyn_cast<UsingDecl>(D)) { // FIXME: This is, unfortunately, linear time. UsingDecl::shadow_iterator Pos = Using->shadow_begin(); diff --git a/clang/tools/libclang/CIndexCXX.cpp b/clang/tools/libclang/CIndexCXX.cpp index ea6f97d..a1be70d 100644 --- a/clang/tools/libclang/CIndexCXX.cpp +++ b/clang/tools/libclang/CIndexCXX.cpp @@ -101,11 +101,11 @@ CXCursor clang_getSpecializedCursorTemplate(CXCursor C) { llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> Result = ClassSpec->getSpecializedTemplateOrPartial(); - if (Result.is<ClassTemplateDecl *>()) - Template = Result.get<ClassTemplateDecl *>(); + if (isa<ClassTemplateDecl *>(Result)) + Template = cast<ClassTemplateDecl *>(Result); else - Template = Result.get<ClassTemplatePartialSpecializationDecl *>(); - + Template = cast<ClassTemplatePartialSpecializationDecl *>(Result); + } else Template = CXXRecord->getInstantiatedFromMemberClass(); } else if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) { diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index a9faba0..72b3468 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -362,7 +362,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic, if (auto *V = DiagsInPedantic.dyn_cast<RecordVec *>()) V->push_back(R); else - DiagsInPedantic.get<RecordSet *>()->insert(R); + cast<RecordSet *>(DiagsInPedantic)->insert(R); } if (!GroupsInPedantic) @@ -389,7 +389,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic, if (auto *V = GroupsInPedantic.dyn_cast<RecordVec *>()) V->push_back(Group); else - GroupsInPedantic.get<RecordSet *>()->insert(Group); + cast<RecordSet *>(GroupsInPedantic)->insert(Group); } } |