Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang-tidy complains on std::string in structs

Tags:

c++

clang-tidy

struct Thing {
  std::string something;
};

Clang-tidy complains:
warning: an exception may be thrown in function 'Thing' which should not throw exceptions [bugprone-exception-escape]

I know about the bugprone-exception-escape.FunctionsThatShouldNotThrow setting, but I could not figure out what to put there to suppress that warning for all structures that contain strings.

Any suggestions?

like image 457
Alex O Avatar asked Oct 21 '25 08:10

Alex O


1 Answers

It is a bug in the check, see https://github.com/llvm/llvm-project/issues/54668, apparently introduced with LLVM 14. Going by the issue description there isn't really much you can do except suppressing it individually for each class.

If that is too much work, you might want to consider disabling the check until they have fixed this. According to the linked issue a fix is already under review: https://reviews.llvm.org/D134588

like image 155
user17732522 Avatar answered Oct 23 '25 21:10

user17732522