r243987 - [Sema] Allocate SmallVector to the right size.

Benjamin Kramer benny.kra at googlemail.com
Tue Aug 4 07:46:06 PDT 2015


Author: d0k
Date: Tue Aug  4 09:46:06 2015
New Revision: 243987

URL: http://llvm.org/viewvc/llvm-project?rev=243987&view=rev
Log:
[Sema] Allocate SmallVector to the right size.

SmallVector::set_size does not reallocate the vector. Sadly I have no
idea how to test this. The vector never has more than one member in all
of the regression tests.

Found by inspection.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=243987&r1=243986&r2=243987&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Aug  4 09:46:06 2015
@@ -1657,7 +1657,7 @@ TemplateDeclInstantiator::VisitCXXMethod
   SmallVector<TemplateParameterList *, 4> TempParamLists;
   unsigned NumTempParamLists = 0;
   if (isFriend && (NumTempParamLists = D->getNumTemplateParameterLists())) {
-    TempParamLists.set_size(NumTempParamLists);
+    TempParamLists.resize(NumTempParamLists);
     for (unsigned I = 0; I != NumTempParamLists; ++I) {
       TemplateParameterList *TempParams = D->getTemplateParameterList(I);
       TemplateParameterList *InstParams = SubstTemplateParams(TempParams);





More information about the cfe-commits mailing list