Issue 140212
Summary [clang-include-cleaner] __attribute__((__cleanup__())) function declaration detection doesn't work if hidden behind a macro
Labels clang-include-cleaner
Assignees
Reporter DaanDeMeyer
    In systemd, we define the following macro:

```c
#define _cleanup_(x) __attribute__((__cleanup__(x)))
```

This breaks the integration for `__cleanup__` that I added in #138669. 

The problem is caused by this bit of code in Analysis.cpp:

```cpp
      auto FID = SM.getFileID(SM.getSpellingLoc(Loc));
      if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
        return;
```

The location passed in `VisitCleanupAttr()` doesn't map to either the main file ID or the preamble file ID.

I assume this happens because we only have a location for the cleanup attribute which is mapped back to the macro. But we don't seem to have a location for the function decl that's in the cleanup macro. Otherwise I'd pass in that location and expect things to work but that doesn't seem to be an option.

Happy to work on a fix, I just don't have a clue what the best way to fix this would be.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to