diff options
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index 1172c4fa21..c22dbf7d54 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -140,6 +140,22 @@ void ValueEnumerator::EnumerateType(const Type *Ty) { EnumerateType(*I); } +/// PurgeAggregateValues - If there are any aggregate values at the end of the +/// value list, remove them and return the count of the remaining values. If +/// there are none, return -1. +int ValueEnumerator::PurgeAggregateValues() { + // If there are no aggregate values at the end of the list, return -1. + if (Values.empty() || Values.back().first->getType()->isFirstClassType()) + return -1; + + // Otherwise, remove aggregate values... + while (!Values.empty() && !Values.back().first->getType()->isFirstClassType()) + Values.pop_back(); + + // ... and return the new size. + return Values.size(); +} + #if 0 |