aaron.ballman added inline comments.
================
Comment at: lib/AST/ASTDumper.cpp:642
- if (!D->param_begin() && D->getNumParams())
- dumpChild([=] { OS << "<<NULL params x " << D->getNumParams() << ">>"; });
- else
- for (const ParmVarDecl *Parameter : D->parameters())
+ if (D->param_begin() || !D->getNumParams())
+ for (const auto *Parameter : D->parameters())
----------------
aaron.ballman wrote:
> You can drop `getNumParams()` here -- if `param_begin()` returns a non-null
> value, `getNumParams()` must return a non-zero value.
>
> (`param_begin()` is implemented in terms of `parameters()`, which calls
> `getNumParams()` when setting up the returned `ArrayRef`.)
It seems that this is needed because the situation can arise when the function
is not fully constructed yet, such as when calling `dump()` under the debugger.
I think this can be more clearly expressed as `if (!D->param_empty() &&
!D->param_begin())`, but should also have some comments explaining that this is
guarding against a situation that only comes up while debugging, and thus is
not covered by any existing test cases.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56753/new/
https://reviews.llvm.org/D56753
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits