MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / preParseCSource

Function preParseCSource

src/extraction/languages/c-cpp.ts:1518–1545  ·  view source on GitHub ↗

C source pre-processing: neutralize `#ifdef __cplusplus` compat-guard * bodies (invisible to a C compiler; `extern "C" {` otherwise errors every * public header), blank declaration-markup macro calls and lone macro lines * (`REDIS_NO_SANITIZE("bounds")` before a definition, jemalloc's diagnostic

(source: string)

Source from the content-addressed store, hash-verified

1516 * kernel prototypes in plain `.h`) — the same content-gated CUDA blank as
1517 * C++. Offset-preserving. */
1518function preParseCSource(source: string): string {
1519 const inner = blankCKernelAnnotations(blankCCplusplusGuardBodies(source));
1520 let blanked = blankCLeadingAttrMacros(
1521 blankLoneMacroLines(
1522 blankCStatementMacroCalls(
1523 blankCTrailingParamAttrMacros(
1524 blankCppAnnotationMacroCalls(
1525 rewriteCPrefixedDeclMacroInitializers(
1526 blankCFileScopePrefixedDeclMacros(
1527 blankCVaArgQualifiedTypeArgs(
1528 blankCTypeKeywordArgs(
1529 blankCParameterizedAnnotationMacros(
1530 blankCAutoInference(blankCSandwichedAnnotations(inner))
1531 )
1532 )
1533 )
1534 )
1535 )
1536 )
1537 )
1538 )
1539 )
1540 );
1541 if (looksLikeCudaSource(blanked)) blanked = blankCudaConstructs(blanked);
1542 // The named-variadic `#define` pass runs AFTER the directive restore — it
1543 // deliberately edits directive lines (see its doc comment).
1544 return blankCNamedVariadicDefineDots(restoreDirectiveLines(source, blanked));
1545}
1546
1547export const cppExtractor: LanguageExtractor = {
1548 // Recover macro-annotated class/struct definitions (`class MYMODULE_API Foo : Base`,

Callers

nothing calls this directly

Tested by

no test coverage detected