You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
The text was updated successfully, but these errors were encountered:
forunix
changed the title
[C++] [Clang-tidy] bugprone-reserved-identifier mistakenly changed JNI API to wrong one
[C++] [clang-tidy] bugprone-reserved-identifier mistakenly changed JNI API to wrong one
Dec 25, 2024
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.
The code of bugprone-reserved-identifier is located at clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp.
The text was updated successfully, but these errors were encountered: