-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Migrate away from PointerUnion::dyn_cast (NFC) #124425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2009,7 +2009,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl, | |
| /// Retrieve the template argument list as written in the sources, | ||
| /// if any. | ||
| const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const { | ||
| if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) | ||
| if (auto *Info = | ||
| dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused by this one. I'd have expected dyn_cast to work here, given the following cast. Or is this the weird case where cast on the non-first pointer union member accepts null?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also thought so, but surprisingly, For this reason, I'm migrating
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #121847 for a related issue, though not sure it's exactly the same. |
||
| return Info->TemplateArgsAsWritten; | ||
| return cast<const ASTTemplateArgumentListInfo *>(ExplicitInfo); | ||
| } | ||
|
|
@@ -2041,7 +2042,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl, | |
|
|
||
| /// Gets the location of the template keyword, if present. | ||
| SourceLocation getTemplateKeywordLoc() const { | ||
| if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) | ||
| if (auto *Info = | ||
| dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) | ||
| return Info->TemplateKeywordLoc; | ||
| return SourceLocation(); | ||
| } | ||
|
|
@@ -2786,7 +2788,8 @@ class VarTemplateSpecializationDecl : public VarDecl, | |
| /// Set the template argument list as written in the sources. | ||
| void | ||
| setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten) { | ||
| if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) | ||
| if (auto *Info = | ||
| dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) | ||
| Info->TemplateArgsAsWritten = ArgsWritten; | ||
| else | ||
| ExplicitInfo = ArgsWritten; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -856,7 +856,7 @@ class Preprocessor { | |
| !PP.CurSubmoduleState->VisibleModules.getGeneration()) | ||
| return nullptr; | ||
|
|
||
| auto *Info = State.dyn_cast<ModuleMacroInfo*>(); | ||
| auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State); | ||
| if (!Info) { | ||
| Info = new (PP.getPreprocessorAllocator()) | ||
| ModuleMacroInfo(cast<MacroDirective *>(State)); | ||
|
|
@@ -885,18 +885,18 @@ class Preprocessor { | |
| } | ||
|
|
||
| ~MacroState() { | ||
| if (auto *Info = State.dyn_cast<ModuleMacroInfo*>()) | ||
| if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State)) | ||
| Info->~ModuleMacroInfo(); | ||
| } | ||
|
|
||
| MacroDirective *getLatest() const { | ||
| if (auto *Info = State.dyn_cast<ModuleMacroInfo*>()) | ||
| if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar for this one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment above. |
||
| return Info->MD; | ||
| return cast<MacroDirective *>(State); | ||
| } | ||
|
|
||
| void setLatest(MacroDirective *MD) { | ||
| if (auto *Info = State.dyn_cast<ModuleMacroInfo*>()) | ||
| if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State)) | ||
| Info->MD = MD; | ||
| else | ||
| State = MD; | ||
|
|
@@ -940,7 +940,7 @@ class Preprocessor { | |
|
|
||
| void setOverriddenMacros(Preprocessor &PP, | ||
| ArrayRef<ModuleMacro *> Overrides) { | ||
| auto *Info = State.dyn_cast<ModuleMacroInfo*>(); | ||
| auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State); | ||
| if (!Info) { | ||
| if (Overrides.empty()) | ||
| return; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.