This class is intended to be used in cases where a class is being used
on a va_list. It provides destruction and copy semantics with small
overhead. This is intended to be used in printf.
Details
- Reviewers
sivachandra lntue - Commits
- rG5561ab3495a4: [libc] Add holder class for va_lists
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libc/src/__support/vlist_holder.h | ||
---|---|---|
17 ↗ | (On Diff #420268) | I vote for something even simpler: ArgList? |
libc/test/src/__support/vlist_holder_test.cpp | ||
15 ↗ | (On Diff #420268) | Should the va_start and va_end be managed by the new class? |
20 ↗ | (On Diff #420268) | Implementing the c++ iterator protocol will help will make the for-loop iteration cleaner? |
rename to ArgList and fix formatting
libc/src/__support/vlist_holder.h | ||
---|---|---|
17 ↗ | (On Diff #420268) | I went with ArgList since it's shorter. |
libc/test/src/__support/vlist_holder_test.cpp | ||
15 ↗ | (On Diff #420268) | The class handles its own va_end, but I don't think it can handle the va_start since its constructor is a new function and you can only create a va_list for the scope of the current function. I could probably create a macro to handle this invisibly, but that's as close as we can get, I think. |
20 ↗ | (On Diff #420268) | I don't think an iterator works here, since the iterator needs to have a type, and the values may be of various types. In addition, there's no end marker or length in a va_list, meaning that a for loop won't know when to end. |