[PATCH] D111625: [clang-tidy] bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader

gehry via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 12 02:41:13 PDT 2021


Sockke created this revision.
Sockke added reviewers: aaron.ballman, njames93, george.burgess.iv, hokein.
Herald added a subscriber: xazax.hun.
Sockke requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

If the Node has an invalid location, it will trigger assert in isInSystemHeader(...).

  #include <iostream>
  /*
    ...
  */

invalid sloc like "__va_list_tag"
coredump with "Assertion `Loc.isValid() && "Can't get file characteristic of invalid loc!"' failed." in getFileCharacteristic(SourceLocation)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111625

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -24,6 +24,8 @@
   if (const auto *D = Node.getDeclContext()->getEnclosingNamespaceContext())
     if (D->isStdNamespace())
       return true;
+  if (Node.getLocation().isInvalid())
+    return false;
   return Node.getASTContext().getSourceManager().isInSystemHeader(
       Node.getLocation());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111625.378928.patch
Type: text/x-patch
Size: 575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211012/80fb46e5/attachment.bin>


More information about the cfe-commits mailing list