On Tue, May 1, 2012 at 8:16 PM, David Blaikie <[email protected]> wrote:
> On Tue, May 1, 2012 at 10:56 AM, Ted Kremenek <[email protected]> wrote: > > Author: kremenek > > Date: Tue May 1 12:56:57 2012 > > New Revision: 155923 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=155923&view=rev > > Log: > > Remove dead code found by static analyzer. > > > > Modified: > > cfe/trunk/lib/Frontend/CompilerInstance.cpp > > > > Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=155923&r1=155922&r2=155923&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) > > +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue May 1 12:56:57 2012 > > @@ -861,11 +861,6 @@ > > // Determine what file we're searching from. > > SourceManager &SourceMgr = getSourceManager(); > > SourceLocation ExpandedImportLoc = > SourceMgr.getExpansionLoc(ImportLoc); > > - const FileEntry *CurFile > > - = > SourceMgr.getFileEntryForID(SourceMgr.getFileID(ExpandedImportLoc)); > > - if (!CurFile) > > - CurFile = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()); > > Would it be practical for Clang to have a warning that caught this (at > least incrementally) - the assignment inside the conditional is dead - > nothing after it reads CurFile, so it would be nice if we warned. (& > then the user would probably be able to see that the rest of this was > silly too) > > > - > > StringRef ModuleName = Path[0].first->getName(); > > SourceLocation ModuleNameLoc = Path[0].second; > > > > > > > It would probably be possible to detect that CurFile is assigned without being ever read afterwards (using the CFG I guess). However we would have to leave it up to the user to detect that the function invocation is now useless, since C++ has unfortunately no notion of purity. -- Matthieu
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
