Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362668

Summary: Running C/C++ Code Analysis on a project containing an assembly file results in a NPE
Product: [Tools] CDT Reporter: Richard Horbach <richard.horbach>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: CLOSED DUPLICATE QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, jensseidel, malaperle, richard.horbach, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Richard Horbach CLA 2011-11-02 09:31:16 EDT
When running C/C++ Code Analysis (RMB > Run C/C++ Code Analysis) on a project containing an assembly file, then a Null Pointer Exception is thrown.
Comment 1 Richard Horbach CLA 2011-11-02 09:32:56 EDT
Stack trace:

java.lang.NullPointerException
	at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:811)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:768)
	at org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache.getAST(CxxModelsCache.java:73)
	at org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache.getAST(CxxModelsCache.java:63)
	at org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker.processFile(AbstractIndexAstChecker.java:73)
	at org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker.processResource(AbstractIndexAstChecker.java:54)
	at org.eclipse.cdt.codan.core.model.AbstractChecker.processResource(AbstractChecker.java:248)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:151)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:97)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:182)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:109)
	at org.eclipse.cdt.codan.internal.ui.actions.RunCodeAnalysis$1.run(RunCodeAnalysis.java:56)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 2 Richard Horbach CLA 2011-11-02 09:36:13 EDT
n CoreModel.isValidTranslationUnit it is tested if a file is a translation unit. The test result depends on the contentType. Types cheader, csource, cxxheader, cxxsource and asmsource (org.eclipse.cdt.core.asmSource) are valid translation units according to this test.

In org.eclipse.cdt.internal.core.model.TranslationUnit, method getAST an ASTTranslationUnit is created from the file contents. For an assembly file this fails and returns null, resulting in the NPE. 

The bug is that C/C++ Code Analysis tries to process assembly files.
Comment 3 Jens Seidel CLA 2012-08-20 09:46:13 EDT
(In reply to comment #2)
> n CoreModel.isValidTranslationUnit it is tested if a file is a translation
> unit. The test result depends on the contentType. Types cheader, csource,
> cxxheader, cxxsource and asmsource (org.eclipse.cdt.core.asmSource) are
> valid translation units according to this test.

Photran (the Fortran frontend) uses also CDT and I got this bug also.

> The bug is that C/C++ Code Analysis tries to process assembly files.

And as it looks like Fortran files ...
Comment 4 Nathan Ridge CLA 2014-07-10 02:30:19 EDT
Looks like this issue was recently fixed in bug 431026.
Comment 5 Marc-André Laperle CLA 2014-07-10 21:59:54 EDT

*** This bug has been marked as a duplicate of bug 431026 ***