[AST] Replace asserts with a condition

As was done for other locations in commit 54272e5b (NFC:
Replace asserts with if() in SourceLocation accessors, 2019-01-07).

Extracted from  https://reviews.llvm.org/D99231
This commit is contained in:
Stephen Kelly 2021-04-14 19:03:33 +01:00
parent cc88d301a0
commit 6559ebd91b
2 changed files with 4 additions and 2 deletions

View File

@ -2267,7 +2267,8 @@ public:
// For a pack expansion, returns the location of the ellipsis. // For a pack expansion, returns the location of the ellipsis.
SourceLocation getEllipsisLoc() const { SourceLocation getEllipsisLoc() const {
assert(isPackExpansion() && "Initializer is not a pack expansion"); if (!isPackExpansion())
return {};
return MemberOrEllipsisLocation; return MemberOrEllipsisLocation;
} }

View File

@ -512,7 +512,8 @@ public:
} }
TypeSourceInfo *getTypeSourceInfo() const { TypeSourceInfo *getTypeSourceInfo() const {
assert(Argument.getKind() == TemplateArgument::Type); if (Argument.getKind() != TemplateArgument::Type)
return nullptr;
return LocInfo.getAsTypeSourceInfo(); return LocInfo.getAsTypeSourceInfo();
} }