Skip to content

Commit

Permalink
combine the calacution of stelen
Browse files Browse the repository at this point in the history
  • Loading branch information
sendaoYan committed Nov 27, 2024
1 parent 0d3768d commit a41e68e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
13 changes: 5 additions & 8 deletions src/hotspot/share/compiler/methodMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,22 @@ bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) con

static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
int match = MethodMatcher::Exact;
size_t len = strlen(name);
if (name[0] == '*') {
if (strlen(name) == 1) {
if (len == 1) {
return MethodMatcher::Any;
}
match |= MethodMatcher::Suffix;
PRAGMA_DIAG_PUSH
PRAGMA_STRINGOP_OVERREAD_IGNORED
// This code can incorrectly cause a "stringop-overread" warning with gcc
memmove(name, name + 1, strlen(name + 1) + 1);
PRAGMA_DIAG_POP
memmove(name, name + 1, len); // Include terminating nul in move.
len--;
}

size_t len = strlen(name);
if (len > 0 && name[len - 1] == '*') {
match |= MethodMatcher::Prefix;
name[--len] = '\0';
}

if (strlen(name) == 0) {
if (len == 0) {
error_msg = "** Not a valid pattern";
return MethodMatcher::Any;
}
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/utilities/compilerWarnings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@
#define PRAGMA_STRINGOP_OVERFLOW_IGNORED
#endif

#ifndef PRAGMA_STRINGOP_OVERREAD_IGNORED
#define PRAGMA_STRINGOP_OVERREAD_IGNORED
#endif

#ifndef PRAGMA_INFINITE_RECURSION_IGNORED
#define PRAGMA_INFINITE_RECURSION_IGNORED
#endif
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/share/utilities/compilerWarnings_gcc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@
#define PRAGMA_STRINGOP_OVERFLOW_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-overflow")
#endif

// Disable -Wstringop-overread which is introduced in GCC 11.
// https://gcc.gnu.org/gcc-11/changes.html
#if !defined(__clang_major__) && (__GNUC__ >= 11)
#define PRAGMA_STRINGOP_OVERREAD_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-overread")
#endif

#define PRAGMA_NONNULL_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wnonnull")

#define PRAGMA_ZERO_AS_NULL_POINTER_CONSTANT_IGNORED \
Expand Down

0 comments on commit a41e68e

Please sign in to comment.