Files
Luan Taraschi 8040a92032 Keep inline asm directives when filtering directives (#9037)
Fixes #8964.

Directive filtering runs over the whole listing, including the region
between `#APP` and `#NO_APP`. That region is the user's own inline asm,
so filtering it changes what the block says. For the case in the issue:

```cpp
int square(int num) {
    asm(".rept 5\nnop\n.endr");
    return num * num;
}
```

`.rept 5` and `.endr` go away and a single `nop` is left, which reads as
one instruction where the source asks for five.

The parser already tracks the region: `updateParsingState` calls
`enterCustomAssembly` on `#APP` and `exitCustomAssembly` on `#NO_APP`,
and `isInCustomAssembly()` was being used only to fix label indentation.
`shouldSkipDirective` now consults it too.

### What still gets dropped

Not everything in the block is the user's. GCC interleaves its own line
markers, as @Alcaro pointed out on the issue:

```
#APP
# 3 "/app/example.cpp" 1
	.rept 5
nop
.endr
# 0 "" 2
	.loc 1 4 5 view .LVU3
# /app/example.cpp:4:     return num * num;
	.loc 1 4 18 is_stmt 0 view .LVU4
#NO_APP
```

So the rule is narrower than "skip filtering inside the block": inside
it, a directive is dropped only when it is a source-location marker.
That set is not a new list, it is the one `SourceLineHandler` already
consumes to build the source mapping (`.loc`, `.d2line`, `.cv_loc`,
`.dbg line`, `.stabn`), exposed as `isSourceLocationDirective`. Anything
the handler does not claim is text the compiler was asked to assemble,
and it stays.

The `#` lines above are comments and are unaffected, they still go with
the comment filter.

### The changed snapshots

`nvcc-x86-host-example` gains three lines: `.section .nv_fatbin, "a"`,
`.align 8` and `.text`, all inside its `#APP` block. The hundreds of
`.quad` lines in that block were already surviving the directive filter,
because `fatbinData:` sets `prevLabel` and `dataDefn` lines under a used
label are kept, so this is three lines added to output that was already
showing the blob, not the blob becoming visible.
`NvccCompiler.removeNvccFatbinaryBlob` is what actually hides it, and it
is unaffected.

No other case in `filters-cases` moves. `bug-577_gcc` and
`bug-577_clang` have `#APP` blocks with no directives in them.

### Tests

Three in `test/asm-parser-tests.ts`: the directives survive, the `.loc`
markers inside the same block still do not, and filtering resumes after
`#NO_APP`. The first and third fail on `main`. I ran the full suite in
`node:22-bookworm`, since `filter-tests.ts` returns early on Windows:
2631 passed.
2026-08-24 19:51:20 -05:00
..
2026-07-14 08:46:10 +01:00
2021-10-05 01:45:05 +02:00
2019-08-21 01:26:16 +02:00
2025-01-29 10:41:03 -06:00
2021-09-13 20:22:27 +02:00
2024-10-26 17:42:22 +02:00
2024-03-08 22:25:09 -06:00
2024-03-08 22:25:09 -06:00
2024-03-08 22:25:09 -06:00
2026-02-08 12:50:20 +01:00
2024-03-08 22:25:09 -06:00