[PATCH] D14204: Fix crash in redundant-void-arg check.

Angel Garcia via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 30 08:41:17 PDT 2015


angelgarcia created this revision.
angelgarcia added reviewers: klimek, LegalizeAdulthood.
angelgarcia added subscribers: alexfh, cfe-commits.

When applying this check to the unit tests, it would hit an assertion:
llvm/tools/clang/lib/Lex/Lexer.cpp:1056: clang::SourceLocation clang::Lexer::getSourceLocation(const char*, unsigned int) const: Assertion `PP && "This doesn't work on raw lexers"' failed.

http://reviews.llvm.org/D14204

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  test/clang-tidy/modernize-redundant-void-arg.cpp

Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===================================================================
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -417,3 +417,13 @@
   // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression
   // CHECK-FIXES: {{^  }}auto void_returner = []() -> void (*)() { return f1; };{{$}}
 }
+
+#define F(A, B)        \
+  struct F_##A##_##B { \
+    F_##A##_##B(void); \
+  };                   \
+  F_##A##_##B::F_##A##_##B(void)
+
+F(Foo, Bar) {
+
+}
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===================================================================
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -128,6 +128,9 @@
 void RedundantVoidArgCheck::removeVoidArgumentTokens(
     const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range,
     StringRef GrammarLocation) {
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+    return;
+
   std::string DeclText =
       Lexer::getSourceText(CharSourceRange::getTokenRange(Range),
                            *Result.SourceManager,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14204.38815.patch
Type: text/x-patch
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151030/9493d411/attachment-0001.bin>


More information about the cfe-commits mailing list