MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / FunctionBase

Function FunctionBase

ASTHelpers.cpp:365–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363//-----------------------------------------------------------------------------
364
365static auto*
366FunctionBase(std::string_view name, QualType returnType, const params_vector& parameters, DeclContext* declCtx)
367{
368 auto& ctx = GetGlobalAST();
369 SmallVector<QualType, 8> argTypes{};
370
371 for(const auto& [_, type] : parameters) {
372 argTypes.push_back(type);
373 }
374
375 FunctionDecl* fdd = FunctionDecl::Create(
376 const_cast<ASTContext&>(ctx),
377 declCtx,
378 {},
379 {},
380 &ctx.Idents.get(name),
381 ctx.getFunctionType(returnType, ArrayRef<QualType>{argTypes}, FunctionProtoType::ExtProtoInfo{}),
382 nullptr,
383 SC_None, // SC_Static,
384 false,
385 false,
386 false,
387 ConstexprSpecKind::Unspecified,
388#if IS_CLANG_NEWER_THAN(20)
389 AssociatedConstraint {}
390#else
391 nullptr
392#endif
393 );
394 fdd->setImplicit(true);
395
396 SmallVector<ParmVarDecl*, 8> paramVarDecls{};
397
398 for(const auto& [name, type] : parameters) {
399 ParmVarDecl* param = Parameter(fdd, name, type);
400 param->setScopeInfo(0, 0);
401 paramVarDecls.push_back(param);
402 }
403
404 fdd->setParams(paramVarDecls);
405
406 return fdd;
407}
408
409FunctionDecl* Function(std::string_view name, QualType returnType, const params_vector& parameters)
410{

Callers 2

FunctionFunction · 0.85
mkStdFunctionDeclFunction · 0.85

Calls 2

ParameterFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected