Purva-Chaudhari updated this revision to Diff 440959. Purva-Chaudhari added a comment.
Added new file for template test CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125944/new/ https://reviews.llvm.org/D125944 Files: clang/include/clang/Sema/Sema.h clang/lib/Interpreter/IncrementalParser.cpp clang/test/Interpreter/templateRecovery.cpp Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -9456,6 +9456,19 @@ SavedPendingLocalImplicitInstantiations; }; + class PerformPendingInstantiationsRAII { + public: + PerformPendingInstantiationsRAII(Sema &S): S(S) {} ; + + ~PerformPendingInstantiationsRAII() { + S.PerformPendingInstantiations(); + assert(S.PendingInstantiations.empty() && + "there shouldn't be any pending instantiations"); + } + private: + Sema &S; + }; + /// A helper class for building up ExtParameterInfos. class ExtParameterInfoBuilder { SmallVector<FunctionProtoType::ExtParameterInfo, 16> Infos; Index: clang/lib/Interpreter/IncrementalParser.cpp =================================================================== --- clang/lib/Interpreter/IncrementalParser.cpp +++ clang/lib/Interpreter/IncrementalParser.cpp @@ -177,6 +177,7 @@ } DiagnosticsEngine &Diags = getCI()->getDiagnostics(); + Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S); if (Diags.hasErrorOccurred()) { TranslationUnitDecl *MostRecentTU = C.getTranslationUnitDecl(); Index: clang/test/Interpreter/templateRecovery.cpp =================================================================== --- /dev/null +++ clang/test/Interpreter/templateRecovery.cpp @@ -0,0 +1,2 @@ +// RUN: clang-repl "template<class T> T f() { return T(); }" "auto ptu2 = f<float>(); err;" \ +// RUN: "auto ptu2 = f<float>();" "int i = 0;"
Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -9456,6 +9456,19 @@ SavedPendingLocalImplicitInstantiations; }; + class PerformPendingInstantiationsRAII { + public: + PerformPendingInstantiationsRAII(Sema &S): S(S) {} ; + + ~PerformPendingInstantiationsRAII() { + S.PerformPendingInstantiations(); + assert(S.PendingInstantiations.empty() && + "there shouldn't be any pending instantiations"); + } + private: + Sema &S; + }; + /// A helper class for building up ExtParameterInfos. class ExtParameterInfoBuilder { SmallVector<FunctionProtoType::ExtParameterInfo, 16> Infos; Index: clang/lib/Interpreter/IncrementalParser.cpp =================================================================== --- clang/lib/Interpreter/IncrementalParser.cpp +++ clang/lib/Interpreter/IncrementalParser.cpp @@ -177,6 +177,7 @@ } DiagnosticsEngine &Diags = getCI()->getDiagnostics(); + Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S); if (Diags.hasErrorOccurred()) { TranslationUnitDecl *MostRecentTU = C.getTranslationUnitDecl(); Index: clang/test/Interpreter/templateRecovery.cpp =================================================================== --- /dev/null +++ clang/test/Interpreter/templateRecovery.cpp @@ -0,0 +1,2 @@ +// RUN: clang-repl "template<class T> T f() { return T(); }" "auto ptu2 = f<float>(); err;" \ +// RUN: "auto ptu2 = f<float>();" "int i = 0;"
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits