<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121089>121089</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [C++] [Clang-tidy] bugprone-reserved-identifier mistakenly changed JNI API to wrong one
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          forunix
      </td>
    </tr>
</table>

<pre>
    Please help to fix the problem of bugprone-reserved-identifier in clang-tidy.

When the bugprone-reserved-identifier option of clang-tidy is enabled, it will change double underscores to one underscore. It will result in a runtime exception of 'java.lang.UnsatisfiedLinkError: No implementation found for xxx'.

As an example it will change Java_cn_xxx_xxx__I to Java_cn_xxx_xxx_I .

The build info is as follows.
```
C/C++: /Users/.../xxJNI.cpp:1740:24: warning: declaration uses identifier 'Java_cn_xxx_xxx__I', which is a reserved identifier[bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp]
C/C++: /Users/.../xxJNI.cpp:1740:24: note: FIX-IT applied suggested code changes
```

The code of bugprone-reserved-identifier is located at clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp.
```
static std::string collapseConsecutive(StringRef Str, char C) {
std::string Result;
std::unique_copy(Str.begin(), Str.end(), std::back_inserter(Result),
[C](char A, char B) { return A == C && B == C; });
return Result;
}

static bool hasReservedDoubleUnderscore(StringRef Name,
const LangOptions &LangOpts) {
if (LangOpts.CPlusPlus)
return Name.contains("");
return Name.starts_with("");
}

static std::optionalstd::string
getDoubleUnderscoreFixup(StringRef Name, const LangOptions &LangOpts) {
if (hasReservedDoubleUnderscore(Name, LangOpts))
return collapseConsecutive(Name, '_');
return std::nullopt;
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVd2OozgTfRrnphRETAjJRS5I8iFlNOpvND_avYuMKcDTjs3aJqHffmU3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