summaryrefslogtreecommitdiffstats
path: root/clang-tidy/modernize/RedundantVoidArgCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tidy/modernize/RedundantVoidArgCheck.cpp')
-rw-r--r--clang-tidy/modernize/RedundantVoidArgCheck.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tidy/modernize/RedundantVoidArgCheck.cpp
index ea49ab7b..46de805e 100644
--- a/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ b/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -1,9 +1,8 @@
//===- RedundantVoidArgCheck.cpp - clang-tidy -----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -102,10 +101,15 @@ void RedundantVoidArgCheck::check(const MatchFinder::MatchResult &Result) {
void RedundantVoidArgCheck::processFunctionDecl(
const MatchFinder::MatchResult &Result, const FunctionDecl *Function) {
if (Function->isThisDeclarationADefinition()) {
- const Stmt *Body = Function->getBody();
SourceLocation Start = Function->getBeginLoc();
- SourceLocation End =
- Body ? Body->getBeginLoc().getLocWithOffset(-1) : Function->getEndLoc();
+ SourceLocation End = Function->getEndLoc();
+ if (const Stmt *Body = Function->getBody()) {
+ End = Body->getBeginLoc();
+ if (End.isMacroID() &&
+ Result.SourceManager->isAtStartOfImmediateMacroExpansion(End))
+ End = Result.SourceManager->getExpansionLoc(End);
+ End = End.getLocWithOffset(-1);
+ }
removeVoidArgumentTokens(Result, SourceRange(Start, End),
"function definition");
} else {
@@ -173,10 +177,8 @@ void RedundantVoidArgCheck::removeVoidArgumentTokens(
void RedundantVoidArgCheck::removeVoidToken(Token VoidToken,
StringRef Diagnostic) {
- SourceLocation VoidLoc(VoidToken.getLocation());
- auto VoidRange =
- CharSourceRange::getTokenRange(VoidLoc, VoidLoc.getLocWithOffset(3));
- diag(VoidLoc, Diagnostic) << FixItHint::CreateRemoval(VoidRange);
+ SourceLocation VoidLoc = VoidToken.getLocation();
+ diag(VoidLoc, Diagnostic) << FixItHint::CreateRemoval(VoidLoc);
}
void RedundantVoidArgCheck::processTypedefNameDecl(