CodeQL library for C/C++
codeql/cpp-all 3.0.1-dev (changelog, source)
Search

Class FunctionDeclarationEntry

A particular declaration or definition of a C/C++ function. For example the declaration and definition of MyFunction in the following code are each a FunctionDeclarationEntry:

void MyFunction();

void MyFunction() {
  DoSomething();
}

Import path

import cpp

Direct supertypes

Indirect supertypes

Predicates

getAParameterDeclarationEntry

Gets the declaration entry for a parameter of this function declaration.

getAPrimaryQlClass

Gets the name of a primary CodeQL class to which this element belongs.

getASpecifier

Gets a specifier associated with this declaration entry.

getAThrownType

Gets a type that is specified to be thrown by the declared function.

getBlock

If this is a function definition, get the block containing the function body.

getCyclomaticComplexity

Gets the cyclomatic complexity of this function:

getDeclaration

Gets the function which is being declared or defined.

getEnclosingElement

Implements Element.getEnclosingElement. A function declaration does not have an enclosing element.

getFunction

Gets the function which is being declared or defined.

getLocation

Gets the location of this declaration entry.

getName

Gets the name of the function.

getNoExceptExpr

If this declaration has a noexcept-specification [N4140 15.4], then this predicate returns the argument to noexcept if one was given.

getNumberOfLines

If this is a function definition, get the number of lines of code associated with it.

getNumberOfParameters

Gets the number of parameters of this function declaration.

getParameterDeclarationEntry

Gets the declaration entry for the nth parameter of this function declaration.

getParameterString

Gets a string representing the parameters of this function declaration.

getThrownType

Gets the ith type specified to be thrown by the declared function (where i is indexed from 0). For example, if a function is declared to throw(int,float), then the thrown type with index 0 would be int, and that with index 1 would be float.

getType

Gets the return type of the function which is being declared or defined.

getTypedefType

Gets the typedef type (if any) used for this function declaration. As an example, the typedef type in the declaration of function foo in the following is Foo:

hasCLinkage

Holds if this declaration entry specifies C linkage:

hasExceptionSpecification

Holds if the declared function has an exception specification [N4140 15.4].

hasVoidParamList

Holds if this declaration entry has a void parameter list.

isDefinition

Holds if this declaration is also a definition of its function.

isImplicit

Holds if this declaration is an implicit function declaration, that is, where a function is used before it is declared (under older C standards, or when there were parse errors).

isNoExcept

Holds if the declared function has an empty noexcept exception specification.

isNoThrow

Holds if the declared function has a throw() exception specification.

isSpecialization

Holds if this declaration is a Template specialization.

Inherited predicates

findRootCause

Gets the source of this element: either itself or a macro that expanded to this element.

from Element
fromSource

Holds if this element may be from source. This predicate holds for all elements, except for those in the dummy file, whose name is the empty string. The dummy file contains declarations that are built directly into the compiler.

from Element
getCanonicalName

Gets the name associated with the corresponding definition (where available), or the name declared by this entry otherwise.

from DeclarationEntry
getFile

Gets the primary file where this element occurs.

from Element
getParentScope

Gets the parent scope of this Element, if any. A scope is a Type (Class / Enum), a Namespace, a BlockStmt, a Function, or certain kinds of Statement.

from Element
getPrimaryQlClasses

Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

from ElementBase
getUnspecifiedType

Gets the type associated with this declaration entry after specifiers have been deeply stripped and typedefs have been resolved.

from DeclarationEntry
hasSpecifier

Holds if this declaration entry has a specifier with the given name.

from DeclarationEntry
isAffectedByMacro

Holds if this element is affected in any way by a macro. All elements that are totally or partially generated by a macro are included, so this is a super-set of isInMacroExpansion.

from Element
isFromTemplateInstantiation

Holds if this Element is a part of a template instantiation (but not the template itself).

from Element
isFromUninstantiatedTemplate

Holds if this Element is part of a template template (not if it is part of an instantiation of template). This means it is represented in the database purely as syntax and without guarantees on the presence or correctness of type-based operations such as implicit conversions.

from Element
isInMacroExpansion

Holds if this element comes from a macro expansion. Only elements that are entirely generated by a macro are included - for elements that partially come from a macro, see isAffectedByMacro.

from Element
toString

Gets a textual representation of this element.

from DeclarationEntry