mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 546981: Process all preprocessor items in model in one pass
The previous code iterated through the preprocessor statements numerous times, this code has the same logic, but iterates through the preprocessor statements less often. Change-Id: If4fcf0a605aabff1f615811f8f528ea66a461136
This commit is contained in:
parent
bcd5dd35bd
commit
c254b95cd6
1 changed files with 11 additions and 12 deletions
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
|
@ -210,20 +211,18 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
fVisibilityStack = new Stack<>();
|
fVisibilityStack = new Stack<>();
|
||||||
fEqualElements = new HashMap<>();
|
fEqualElements = new HashMap<>();
|
||||||
|
|
||||||
// includes
|
for (IASTPreprocessorStatement statement : ast.getAllPreprocessorStatements()) {
|
||||||
final IASTPreprocessorIncludeStatement[] includeDirectives = ast.getIncludeDirectives();
|
if (statement instanceof IASTPreprocessorIncludeStatement) {
|
||||||
for (IASTPreprocessorIncludeStatement includeDirective : includeDirectives) {
|
if (isLocalToFile(statement)) {
|
||||||
if (isLocalToFile(includeDirective)) {
|
createInclusion(fTranslationUnit, (IASTPreprocessorIncludeStatement) statement);
|
||||||
createInclusion(fTranslationUnit, includeDirective);
|
}
|
||||||
}
|
} else if (statement instanceof IASTPreprocessorMacroDefinition) {
|
||||||
}
|
if (isLocalToFile(statement)) {
|
||||||
// Macros
|
createMacro(fTranslationUnit, (IASTPreprocessorMacroDefinition) statement);
|
||||||
final IASTPreprocessorMacroDefinition[] macroDefinitions = ast.getMacroDefinitions();
|
}
|
||||||
for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions) {
|
|
||||||
if (isLocalToFile(macroDefinition)) {
|
|
||||||
createMacro(fTranslationUnit, macroDefinition);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
final IASTDeclaration[] declarations = ast.getDeclarations(true);
|
final IASTDeclaration[] declarations = ast.getDeclarations(true);
|
||||||
for (IASTDeclaration declaration : declarations) {
|
for (IASTDeclaration declaration : declarations) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue