Possible memory leak.

Hello!

I think I might found a memory leak.

Assume following function and class ASTMutationAction

bool processFile(std::string inFile){
auto_ptr compiler(new CompilerInstance);
compiler->createDiagnostics(0, NULL);
assert(compiler->hasDiagnostics());
const char *args[] =
{
“-cc1”,
inFile.c_str()
};
std::cout << outFile << std::endl;
clang::CompilerInvocation::CreateFromArgs(
compiler->getInvocation(),
args,
args + 2,
compiler->getDiagnostics());
llvm::OwningPtrclang::ASTFrontendAction action(new ASTMutationAction());
compiler->ExecuteAction(*action);
}

class ASTMutationAction : public ASTFrontendAction {
protected:
virtual ASTConsumer* CreateASTConsumer(CompilerInstance& compiler,
llvm::StringRef){
return new ASTConsumer();
}
};

In processFile(std::string) each time I pass path to a file. I’m getting paths via directory traversal. So amount of executions of that function is always somewhere between 1000 and 40000 times. Although ASTConsumer class is not implemented the amount of memory used by the process is constantly growing. As soon as line ‘compiler->ExecuteAction(*action);’ is commented there is no memory leakage.

I though it was somewhere in my code, but even when I deleted all implementation from ASTMutationAction class and left only stub, the memory consumption continued to increase.

Is this a bug or I use clang somehow wrong?

best regards,
Andrey Tarasevich.