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

Function preParseCppSource

src/extraction/languages/c-cpp.ts:1904–1937  ·  view source on GitHub ↗
(source: string, filePath?: string)

Source from the content-addressed store, hash-verified

1902}
1903
1904function preParseCppSource(source: string, filePath?: string): string {
1905 const rawStrings = maskCppRawStrings(source);
1906 source = flattenMidStatementConditionals(rewriteCppAccessMacros(rewriteFoundationEnumMacros(rawStrings.source)));
1907 // blankCLeadingAttrMacros runs AFTER the api-prefix blank so a stacked
1908 // `FMT_NORETURN FMT_API void f(…)` reduces to the `MACRO Ret name(` shape
1909 // it matches (the _API token is already spaces by then). The C++ leading
1910 // blank runs after the pointer, trailing and declarator ones, so the
1911 // declaration it looks for (`Type* name(`, `Type name;`) is already free of
1912 // their macros.
1913 let blanked = blankLoneMacroLines(
1914 blankCppLeadingAttributeMacros(
1915 blankCLeadingAttrMacros(
1916 blankCppAnnotationMacroCalls(
1917 blankCppDeclaratorAttributeMacros(
1918 blankCppTrailingAttributeMacros(
1919 blankCppPointerAnnotationMacros(
1920 blankCppInlineAnnotationMacros(
1921 blankCppApiPrefixMacros(blankCppInlineMacros(blankCppExportMacros(normalizeCppComInterfaces(source))))
1922 )
1923 )
1924 )
1925 )
1926 )
1927 )
1928 )
1929 );
1930 const lower = filePath ? filePath.toLowerCase() : '';
1931 if (lower.endsWith('.metal')) {
1932 blanked = blankMetalAttributes(blanked);
1933 } else if (lower.endsWith('.cu') || lower.endsWith('.cuh') || looksLikeCudaSource(source)) {
1934 blanked = blankCudaConstructs(blanked);
1935 }
1936 return rawStrings.restore(restoreDirectiveLines(source, blanked));
1937}
1938
1939/**
1940 * Blank an unknown attribute macro sitting in front of a C function

Callers

nothing calls this directly

Tested by

no test coverage detected