[PATCH] D118437: [NFC] [Modules] Refactor ODR checking for default template argument in ASTReader
Nathan Sidwell via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 7 12:36:36 PST 2022
urnathan added a comment.
Looks like a good cleanup. Let me know what you think about the idea of retaining the switch.
================
Comment at: clang/lib/Serialization/ASTReader.cpp:10176-10184
+ if (auto *TTP = dyn_cast<TemplateTypeParmDecl>(D))
+ return TTP->hasDefaultArgument() &&
+ !TTP->defaultArgumentWasInherited();
+ if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D))
+ return NTTP->hasDefaultArgument() &&
+ !NTTP->defaultArgumentWasInherited();
+ auto *TTP = cast<TemplateTemplateParmDecl>(D);
----------------
Rather than use dyn_cast, can't you use the switch(getKind()) idiom of the original? That'll reduce the number of virtual calls won't it? Bonus points for passing getKind() into the lambda so the compiler has a chance of noticing a loop unswitching possibility?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118437/new/
https://reviews.llvm.org/D118437
More information about the cfe-commits
mailing list