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)
| 1506 | * kernel prototypes in plain `.h`) — the same content-gated CUDA blank as |
| 1507 | * C++. Offset-preserving. */ |
| 1508 | function preParseCSource(source: string): string { |
| 1509 | const inner = blankCKernelAnnotations(blankCCplusplusGuardBodies(source)); |
| 1510 | let blanked = blankCLeadingAttrMacros( |
| 1511 | blankLoneMacroLines( |
| 1512 | blankCStatementMacroCalls( |
| 1513 | blankCTrailingParamAttrMacros( |
| 1514 | blankCppAnnotationMacroCalls( |
| 1515 | rewriteCPrefixedDeclMacroInitializers( |
| 1516 | blankCFileScopePrefixedDeclMacros( |
| 1517 | blankCVaArgQualifiedTypeArgs( |
| 1518 | blankCTypeKeywordArgs( |
| 1519 | blankCParameterizedAnnotationMacros( |
| 1520 | blankCAutoInference(blankCSandwichedAnnotations(inner)) |
| 1521 | ) |
| 1522 | ) |
| 1523 | ) |
| 1524 | ) |
| 1525 | ) |
| 1526 | ) |
| 1527 | ) |
| 1528 | ) |
| 1529 | ) |
| 1530 | ); |
| 1531 | if (looksLikeCudaSource(blanked)) blanked = blankCudaConstructs(blanked); |
| 1532 | // The named-variadic `#define` pass runs AFTER the directive restore — it |
| 1533 | // deliberately edits directive lines (see its doc comment). |
| 1534 | return blankCNamedVariadicDefineDots(restoreDirectiveLines(source, blanked)); |
| 1535 | } |
| 1536 | |
| 1537 | export const cppExtractor: LanguageExtractor = { |
| 1538 | // Recover macro-annotated class/struct definitions (`class MYMODULE_API Foo : Base`, |
nothing calls this directly
no test coverage detected