r285192 - Fix use-after-scope in ASTContext.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 05:51:46 PDT 2016


Author: d0k
Date: Wed Oct 26 07:51:45 2016
New Revision: 285192

URL: http://llvm.org/viewvc/llvm-project?rev=285192&view=rev
Log:
Fix use-after-scope in ASTContext.

Extend lifetime of ExceptionTypeStorage, as it is referenced by
CanonicalEPI and used outside the block (ExceptionSpec.Exceptions is an
ArrayRef)

Patch by Sam McCall!

Differential Revision: https://reviews.llvm.org/D25983

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=285192&r1=285191&r2=285192&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Oct 26 07:51:45 2016
@@ -3230,13 +3230,13 @@ QualType ASTContext::getFunctionTypeInte
     for (unsigned i = 0; i != NumArgs; ++i)
       CanonicalArgs.push_back(getCanonicalParamType(ArgArray[i]));
 
+    llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
     FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
     CanonicalEPI.HasTrailingReturn = false;
 
     if (IsCanonicalExceptionSpec) {
       // Exception spec is already OK.
     } else if (NoexceptInType) {
-      llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
       switch (EPI.ExceptionSpec.Type) {
       case EST_Unparsed: case EST_Unevaluated: case EST_Uninstantiated:
         // We don't know yet. It shouldn't matter what we pick here; no-one




More information about the cfe-commits mailing list