[clang] 6559ebd - [AST] Replace asserts with a condition
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 14 13:15:05 PDT 2021
Author: Stephen Kelly
Date: 2021-04-14T21:14:05+01:00
New Revision: 6559ebd91b70f8d2ed82e19539ee09c5220159c2
URL: https://github.com/llvm/llvm-project/commit/6559ebd91b70f8d2ed82e19539ee09c5220159c2
DIFF: https://github.com/llvm/llvm-project/commit/6559ebd91b70f8d2ed82e19539ee09c5220159c2.diff
LOG: [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
Added:
Modified:
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TemplateBase.h
Removed:
################################################################################
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index bb99ab1373ba5..bbf7ecf6712a3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2267,7 +2267,8 @@ class CXXCtorInitializer final {
// For a pack expansion, returns the location of the ellipsis.
SourceLocation getEllipsisLoc() const {
- assert(isPackExpansion() && "Initializer is not a pack expansion");
+ if (!isPackExpansion())
+ return {};
return MemberOrEllipsisLocation;
}
diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h
index 1671637521e24..19f2cadc1f2b7 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -512,7 +512,8 @@ class TemplateArgumentLoc {
}
TypeSourceInfo *getTypeSourceInfo() const {
- assert(Argument.getKind() == TemplateArgument::Type);
+ if (Argument.getKind() != TemplateArgument::Type)
+ return nullptr;
return LocInfo.getAsTypeSourceInfo();
}
More information about the cfe-commits
mailing list