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.IASTPreprocessorIncludeStatement;
|
||||
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.IASTProblemDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||
|
@ -210,20 +211,18 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
fVisibilityStack = new Stack<>();
|
||||
fEqualElements = new HashMap<>();
|
||||
|
||||
// includes
|
||||
final IASTPreprocessorIncludeStatement[] includeDirectives = ast.getIncludeDirectives();
|
||||
for (IASTPreprocessorIncludeStatement includeDirective : includeDirectives) {
|
||||
if (isLocalToFile(includeDirective)) {
|
||||
createInclusion(fTranslationUnit, includeDirective);
|
||||
}
|
||||
}
|
||||
// Macros
|
||||
final IASTPreprocessorMacroDefinition[] macroDefinitions = ast.getMacroDefinitions();
|
||||
for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions) {
|
||||
if (isLocalToFile(macroDefinition)) {
|
||||
createMacro(fTranslationUnit, macroDefinition);
|
||||
for (IASTPreprocessorStatement statement : ast.getAllPreprocessorStatements()) {
|
||||
if (statement instanceof IASTPreprocessorIncludeStatement) {
|
||||
if (isLocalToFile(statement)) {
|
||||
createInclusion(fTranslationUnit, (IASTPreprocessorIncludeStatement) statement);
|
||||
}
|
||||
} else if (statement instanceof IASTPreprocessorMacroDefinition) {
|
||||
if (isLocalToFile(statement)) {
|
||||
createMacro(fTranslationUnit, (IASTPreprocessorMacroDefinition) statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Declarations
|
||||
final IASTDeclaration[] declarations = ast.getDeclarations(true);
|
||||
for (IASTDeclaration declaration : declarations) {
|
||||
|
|
Loading…
Add table
Reference in a new issue