void MyChecker::checkCallExpr (const CallExpr *CE, CheckerContext &C) const { const FunctionDecl *FD = C.getCalleeDecl(CE); if (FD && FD->getNumParams() == 0 && !CE->getNumArgs()) { // Do something if function is called without arguments } }
void MyChecker::checkCallExpr (const CallExpr *CE, CheckerContext &C) const { const FunctionDecl *FD = C.getCalleeDecl(CE); if (FD && FD->getQualifiedNameAsString().startswith("std::") { // Do something if function is called from the std namespace } }In this example, the checkCallExpr method checks if a function is called from the std namespace. The getCalleeDecl method is used to obtain a pointer to the called function's declaration. The example code then checks if the function is qualified by the std namespace. Package/Library: LLVM/Clang API Overall, the CheckerContext getCalleeDecl method is useful for obtaining information about the called function in C++ static code analysis tools. This method is part of the LLVM/Clang API and is used in various packages and libraries that utilize these tools.