r219813 - Revert "Fix late template parsing leak with incremental processing"
Reid Kleckner
reid at kleckner.net
Wed Oct 15 10:22:56 PDT 2014
Author: rnk
Date: Wed Oct 15 12:22:56 2014
New Revision: 219813
URL: http://llvm.org/viewvc/llvm-project?rev=219813&view=rev
Log:
Revert "Fix late template parsing leak with incremental processing"
This reverts commit r219810.
The test suite appears broken.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/unittests/Frontend/FrontendActionTest.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=219813&r1=219812&r2=219813&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Oct 15 12:22:56 2014
@@ -1155,7 +1155,6 @@ private:
void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
static void LateTemplateParserCallback(void *P, LateParsedTemplate &LPT);
- static void LateTemplateParserCleanupCallback(void *P);
Sema::ParsingClassState
PushParsingClass(Decl *TagOrTemplate, bool TopLevelClass, bool IsInterface);
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=219813&r1=219812&r2=219813&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct 15 12:22:56 2014
@@ -480,16 +480,11 @@ public:
/// \brief Callback to the parser to parse templated functions when needed.
typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
- typedef void LateTemplateParserCleanupCB(void *P);
LateTemplateParserCB *LateTemplateParser;
- LateTemplateParserCleanupCB *LateTemplateParserCleanup;
void *OpaqueParser;
- void SetLateTemplateParser(LateTemplateParserCB *LTP,
- LateTemplateParserCleanupCB *LTPCleanup,
- void *P) {
+ void SetLateTemplateParser(LateTemplateParserCB *LTP, void *P) {
LateTemplateParser = LTP;
- LateTemplateParserCleanup = LTPCleanup;
OpaqueParser = P;
}
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=219813&r1=219812&r2=219813&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Oct 15 12:22:56 2014
@@ -510,13 +510,6 @@ namespace {
};
}
-void Parser::LateTemplateParserCleanupCallback(void *P) {
- // While this RAII helper doesn't bracket any actual work, the destructor will
- // clean up annotations that were created during ActOnEndOfTranslationUnit
- // when incremental processing is enabled.
- DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(((Parser *)P)->TemplateIds);
-}
-
/// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
/// action tells us to. This returns true if the EOF was encountered.
bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
@@ -549,10 +542,7 @@ bool Parser::ParseTopLevelDecl(DeclGroup
case tok::eof:
// Late template parsing can begin.
if (getLangOpts().DelayedTemplateParsing)
- Actions.SetLateTemplateParser(LateTemplateParserCallback,
- PP.isIncrementalProcessingEnabled() ?
- LateTemplateParserCleanupCallback : nullptr,
- this);
+ Actions.SetLateTemplateParser(LateTemplateParserCallback, this);
if (!PP.isIncrementalProcessingEnabled())
Actions.ActOnEndOfTranslationUnit();
//else don't tell Sema that we ended parsing: more input might come.
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=219813&r1=219812&r2=219813&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Oct 15 12:22:56 2014
@@ -672,9 +672,6 @@ void Sema::ActOnEndOfTranslationUnit() {
}
PerformPendingInstantiations();
- if (LateTemplateParserCleanup)
- LateTemplateParserCleanup(OpaqueParser);
-
CheckDelayedMemberExceptionSpecs();
}
Modified: cfe/trunk/unittests/Frontend/FrontendActionTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/FrontendActionTest.cpp?rev=219813&r1=219812&r2=219813&view=diff
==============================================================================
--- cfe/trunk/unittests/Frontend/FrontendActionTest.cpp (original)
+++ cfe/trunk/unittests/Frontend/FrontendActionTest.cpp Wed Oct 15 12:22:56 2014
@@ -14,7 +14,6 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Lex/Preprocessor.h"
-#include "clang/Sema/Sema.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/MemoryBuffer.h"
#include "gtest/gtest.h"
@@ -26,13 +25,10 @@ namespace {
class TestASTFrontendAction : public ASTFrontendAction {
public:
- TestASTFrontendAction(bool enableIncrementalProcessing = false,
- bool actOnEndOfTranslationUnit = false)
- : EnableIncrementalProcessing(enableIncrementalProcessing),
- ActOnEndOfTranslationUnit(actOnEndOfTranslationUnit) { }
+ TestASTFrontendAction(bool enableIncrementalProcessing = false)
+ : EnableIncrementalProcessing(enableIncrementalProcessing) { }
bool EnableIncrementalProcessing;
- bool ActOnEndOfTranslationUnit;
std::vector<std::string> decl_names;
virtual bool BeginSourceFileAction(CompilerInstance &ci, StringRef filename) {
@@ -44,22 +40,15 @@ public:
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
- return llvm::make_unique<Visitor>(CI, ActOnEndOfTranslationUnit,
- decl_names);
+ return llvm::make_unique<Visitor>(decl_names);
}
private:
class Visitor : public ASTConsumer, public RecursiveASTVisitor<Visitor> {
public:
- Visitor(CompilerInstance &ci, bool actOnEndOfTranslationUnit,
- std::vector<std::string> &decl_names) :
- CI(ci), ActOnEndOfTranslationUnit(actOnEndOfTranslationUnit),
- decl_names_(decl_names) {}
+ Visitor(std::vector<std::string> &decl_names) : decl_names_(decl_names) {}
virtual void HandleTranslationUnit(ASTContext &context) {
- if (ActOnEndOfTranslationUnit) {
- CI.getSema().ActOnEndOfTranslationUnit();
- }
TraverseDecl(context.getTranslationUnitDecl());
}
@@ -69,8 +58,6 @@ private:
}
private:
- CompilerInstance &CI;
- bool ActOnEndOfTranslationUnit;
std::vector<std::string> &decl_names_;
};
};
@@ -115,34 +102,6 @@ TEST(ASTFrontendAction, IncrementalParsi
EXPECT_EQ("x", test_action.decl_names[1]);
}
-TEST(ASTFrontendAction, LateTemplateIncrementalParsing) {
- CompilerInvocation *invocation = new CompilerInvocation;
- invocation->getLangOpts()->CPlusPlus = true;
- invocation->getLangOpts()->DelayedTemplateParsing = true;
- invocation->getPreprocessorOpts().addRemappedFile(
- "test.cc", MemoryBuffer::getMemBuffer(
- "template<typename T> struct A { A(T); T data; };\n"
- "template<typename T> struct B: public A<T> {\n"
- " B();\n"
- " B(B const& b): A<T>(b.data) {}\n"
- "};\n"
- "B<char> c() { return B<char>(); }\n").release());
- invocation->getFrontendOpts().Inputs.push_back(FrontendInputFile("test.cc",
- IK_CXX));
- invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
- invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
- CompilerInstance compiler;
- compiler.setInvocation(invocation);
- compiler.createDiagnostics();
-
- TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true,
- /*actOnEndOfTranslationUnit=*/true);
- ASSERT_TRUE(compiler.ExecuteAction(test_action));
- ASSERT_EQ(13U, test_action.decl_names.size());
- EXPECT_EQ("A", test_action.decl_names[0]);
- EXPECT_EQ("c", test_action.decl_names[12]);
-}
-
struct TestPPCallbacks : public PPCallbacks {
TestPPCallbacks() : SeenEnd(false) {}
More information about the cfe-commits
mailing list