1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 12:25:35 +02:00

Don't report unknown built-in functions as problems.

This commit is contained in:
Sergey Prigogin 2013-04-03 17:27:28 -07:00
parent 3f6d140713
commit fa881229a6
4 changed files with 28 additions and 10 deletions

View file

@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
public class ProblemBindingChecker extends AbstractIndexAstChecker {
@ -145,6 +146,10 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker {
if (id != IProblemBinding.SEMANTIC_NAME_NOT_FOUND) {
return PROCESS_CONTINUE;
}
if (problemBinding.getID() == IProblemBinding.SEMANTIC_NAME_NOT_FOUND &&
CharArrayUtils.startsWith(problemBinding.getNameCharArray(), "__builtin_")) { //$NON-NLS-1$
return PROCESS_CONTINUE; // Ignore an unknown built-in.
}
if (isFunctionCall(name, parentNode)) {
handleFunctionProblem(name, problemBinding, contextFlagsString);
} else if (parentNode instanceof IASTFieldReference) {
@ -152,7 +157,7 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker {
} else if (parentNode instanceof IASTNamedTypeSpecifier) {
reportProblem(ERR_ID_TypeResolutionProblem, name, name.getRawSignature(), contextFlagsString);
} else {
// Probably a variable
// Probably a variable.
handleVariableProblem(name, contextFlagsString);
}
}

View file

@ -109,13 +109,13 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
function("void", "__builtin_va_end", "va_list");
function("void", "__builtin_va_copy", "va_list", "va_list");
// Gcc 4.6.0, Section 6.48
// GCC 4.6.0, Section 6.48
function("void*", "__builtin_return_address", "unsigned int");
function("void*", "__builtin_extract_return_address", "void*");
function("void*", "__builtin_frob_return_address", "void*");
function("void*", "__builtin_frame_address", "unsigned int");
// Gcc 4.6.0, Section 6.51
// GCC 4.6.0, Section 6.51
String[] types= {"int", "long", "long long", "unsigned int", "unsigned long", "unsigned long long"};
for (String type : types) {
// Manual does not mention volatile, however functions can be used for ptr to volatile
@ -137,7 +137,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
}
function("void", "__sync_synchronize");
// Gcc 4.6.0, Section 6.52
// GCC 4.8, Section 6.52
for (String type : types) {
// Manual does not mention volatile, however functions can be used for ptr to volatile
String typePtr= "volatile " + type + "*";
@ -171,7 +171,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
function("bool", "__atomic_is_lock_free", "size_t", "void*");
}
// GCC 4.8.0, Section 6.55 (incomplete)
// GCC 4.8, Section 6.55 (incomplete)
function("void", "__builtin_abort", "void");
function("int", "__builtin_abs", "int");
function("double", "__builtin_acos", "double");

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.parser.FileContent;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ISignificantMacros;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.FileContentKey;
@ -72,6 +73,7 @@ import org.eclipse.osgi.util.NLS;
* @since 4.0
*/
abstract public class PDOMWriter {
private static final boolean REPORT_UNKNOWN_BUILTINS = false;
public static class FileInAST {
final IASTPreprocessorIncludeStatement includeStatement;
@ -343,9 +345,14 @@ abstract public class PDOMWriter {
binding instanceof ICPPFunctionTemplate)) {
na[0]= null;
} else if (binding instanceof IProblemBinding) {
fStatistics.fProblemBindingCount++;
if (fShowProblems) {
reportProblem((IProblemBinding) binding);
IProblemBinding problemBinding = (IProblemBinding) binding;
if (REPORT_UNKNOWN_BUILTINS ||
problemBinding.getID() != IProblemBinding.BINDING_NOT_FOUND ||
!CharArrayUtils.startsWith(problemBinding.getNameCharArray(), "__builtin_")) { //$NON-NLS-1$
fStatistics.fProblemBindingCount++;
if (fShowProblems) {
reportProblem(problemBinding);
}
}
} else if (name.isReference()) {
if (binding instanceof ICPPTemplateParameter ||

View file

@ -58,6 +58,7 @@ import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ISemanticToken;
@ -1321,7 +1322,7 @@ public class SemanticHighlightings {
public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode();
if (node.getTranslationUnit().isBasedOnIncompleteIndex()) {
// Do not highlight problems is the AST is unreliable.
// Do not highlight problems if the AST is unreliable.
return false;
}
if (node instanceof IASTProblem) {
@ -1329,6 +1330,11 @@ public class SemanticHighlightings {
}
IBinding binding= token.getBinding();
if (binding instanceof IProblemBinding) {
IProblemBinding problemBinding = (IProblemBinding) binding;
if (problemBinding.getID() == IProblemBinding.SEMANTIC_NAME_NOT_FOUND &&
CharArrayUtils.startsWith(problemBinding.getNameCharArray(), "__builtin_")) { //$NON-NLS-1$
return false; // Ignore an unknown built-in.
}
return true;
}
return false;