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

Method InsertTemplateArgsObjectParam

CodeGenerator.cpp:1221–1240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219//-----------------------------------------------------------------------------
1220
1221void CodeGenerator::InsertTemplateArgsObjectParam(const TemplateParamObjectDecl& param)
1222{
1223 PrintingPolicy pp{GetGlobalAST().getLangOpts()};
1224 pp.adjustForCPlusPlus();
1225
1226 if(auto varName = GetName(param); not mSeenDecls.contains(varName)) {
1227 std::string init{};
1228 ::llvm::raw_string_ostream stream{init};
1229 param.printAsInit(stream, pp);
1230
1231 // https://eel.is/c++draft/temp.param#8 says the variable is `static const`. However, to make the
1232 // compiler accept the generated code the storage object must be constexpr.
1233 // The initialization itself is on the lowest level, int's, floating point or nested structs with them. For
1234 // classes this could fail a all fields even the hidden ones are observed. However, for NTTPs the rule is that
1235 // only structs/classes with _only_ public data members are accepted.
1236 mOutputFormatHelper.AppendSemiNewLine(
1237 "static constexpr ", GetName(param.getType().getUnqualifiedType()), " ", varName, init);
1238 mSeenDecls[varName] = true;
1239 }
1240}
1241//-----------------------------------------------------------------------------
1242
1243void CodeGenerator::InsertTemplateArgsObjectParam(const ArrayRef<TemplateArgument>& array)

Callers

nothing calls this directly

Calls 2

GetNameFunction · 0.85
AppendSemiNewLineMethod · 0.80

Tested by

no test coverage detected