[LLVMdev] A bug or a feature?
Anton Yartsev
anton.yartsev at gmail.com
Mon Mar 10 16:24:07 PDT 2014
Hi,
I've run Clang Static Analyzer checker alpha.cplusplus.NewDeleteLeaks
over LLVM codebase to detect false-positives and at the same time
eliminate memory leaks. The majority of leaks were detected in
lib/Target/* and lib/MC/*. In all cases the similar trick was detected
as a leak (example from
lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp) :
static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter
*Emitter,
const MCSubtargetInfo &STI, bool
RelaxAll,
bool NoExecStack) {
MCStreamer *S =
createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);
new SparcTargetELFStreamer(*S);
1 Memory is allocated ?
return S;
2 ? Potential memory leak
}
Have not got why is this SparcTargetELFStreamer created dynamically and
not assigned.
Can anybody please explain is this a trick or a trouble?
The similar pattern was detected in
lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp
lib/MC/MCELFStreamer.cpp
lib/MC/WinCOFFStreamer.cpp
lib/MC/MCMachOStreamer.cpp
--
Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140311/61c395d6/attachment.html>
More information about the llvm-dev
mailing list