iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

Fix: startswith() is deprecated: Use starts_with instead #5002

Closed Rtoax closed 4 months ago

Rtoax commented 4 months ago

llvm [0] startswith() is deprecated in commit 5ac12951b4e9 ("[ADT] Deprecate StringRef::{starts,ends}with (#75491)"), and it's totally removed in commit 4ec9a662d388 ("[ADT] Remove StringRef::{startswith,endswith} (#89548)").

Warning detail:

$ make
[...]
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc:341:37: warning: ‘bool llvm::StringRef::startswith(llvm::StringRef) const’ is deprecated: Use starts_with instead [-Wdeprecated-declarations]
  341 |         if (!A->getName().startswith("maps"))
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/clang/Basic/DiagnosticIDs.h:19,
                 from /usr/include/clang/Basic/Diagnostic.h:17,
                 from /usr/include/clang/AST/NestedNameSpecifier.h:18,
                 from /usr/include/clang/AST/Type.h:21,
                 from /usr/include/clang/AST/CanonicalType.h:17,
                 from /usr/include/clang/AST/ASTContext.h:18,
                 from /home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc:23:
/usr/include/llvm/ADT/StringRef.h:263:29: note: declared here
  263 |         "starts_with") bool startswith(StringRef Prefix) const {
      |                             ^~~~~~~~~~
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::ProbeVisitor::assignsExtPtr(clang::Expr*, int*)’:
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc:393:39: warning: ‘bool llvm::StringRef::startswith(llvm::StringRef) const’ is deprecated: Use starts_with instead [-Wdeprecated-declarations]
  393 |           if (!A->getName().startswith("maps"))
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/llvm/ADT/StringRef.h:263:29: note: declared here
  263 |         "starts_with") bool startswith(StringRef Prefix) const {
      |                             ^~~~~~~~~~
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::BTypeVisitor::VisitCallExpr(clang::CallExpr*)’:
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc:940:37: warning: ‘bool llvm::StringRef::startswith(llvm::StringRef) const’ is deprecated: Use starts_with instead [-Wdeprecated-declarations]
  940 |         if (!A->getName().startswith("maps"))
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/llvm/ADT/StringRef.h:263:29: note: declared here
  263 |         "starts_with") bool startswith(StringRef Prefix) const {
      |                             ^~~~~~~~~~
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::BTypeVisitor::VisitVarDecl(clang::VarDecl*)’:
/home/rongtao/Git/iovisor/bcc/src/cc/frontends/clang/b_frontend_action.cc:1458:33: warning: ‘bool llvm::StringRef::startswith(llvm::StringRef) const’ is deprecated: Use starts_with instead [-Wdeprecated-declarations]
 1458 |     if (!A->getName().startswith("maps"))
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/llvm/ADT/StringRef.h:263:29: note: declared here
  263 |         "starts_with") bool startswith(StringRef Prefix) const {
      |                             ^~~~~~~~~~
[ 73%] Built target clang_frontend-objects

[0] https://github.com/llvm/llvm-project