[clang-tidy] Test username substitution in TODO() check.

Summary:
This patch depends on D5501.
Check user name substitution more specifically by specifying it via the new
-config= option.
This also lets clang-tidy tests specify clang-tidy options before the '--'
when using check_clang_tidy_fix.sh.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

Differential Revision: http://reviews.llvm.org/D5502

llvm-svn: 218515
This commit is contained in:
Alexander Kornienko 2014-09-26 12:44:30 +00:00
parent 82d5c5139f
commit 761c25bc15
4 changed files with 14 additions and 14 deletions

View File

@ -1,4 +1,4 @@
// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-casting %t -x c // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-casting %t -- -x c
// REQUIRES: shell // REQUIRES: shell
void f(const char *cpc) { void f(const char *cpc) {

View File

@ -6,17 +6,17 @@
# [optional compiler arguments] # [optional compiler arguments]
# #
# Example: # Example:
# // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-include-order %t -isystem $(dirname %s)/Inputs/Headers # // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-include-order %t -- -isystem $(dirname %s)/Inputs/Headers
# // REQUIRES: shell # // REQUIRES: shell
INPUT_FILE=$1 INPUT_FILE=$1
CHECK_TO_RUN=$2 CHECK_TO_RUN=$2
TEMPORARY_FILE=$3.cpp TEMPORARY_FILE=$3.cpp
# Feed the rest arguments to clang-tidy after --. # Feed the rest arguments to clang-tidy.
shift 3 shift 3
CLANG_TIDY_ARGS=--std=c++11 if [ "$#" -eq 0 ] ; then
if [ "$#" -gt 0 ] ; then # Default to -- --std=c++11
CLANG_TIDY_ARGS=$* set - -- --std=c++11
fi fi
set -o errexit set -o errexit
@ -26,8 +26,8 @@ set -o errexit
# lines which could potentially trigger formatting-related checks. # lines which could potentially trigger formatting-related checks.
sed 's#// *CHECK-[A-Z-]*:.*#//#' ${INPUT_FILE} > ${TEMPORARY_FILE} sed 's#// *CHECK-[A-Z-]*:.*#//#' ${INPUT_FILE} > ${TEMPORARY_FILE}
clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" \ clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" "$@" \
-- ${CLANG_TIDY_ARGS} > ${TEMPORARY_FILE}.msg 2>&1 > ${TEMPORARY_FILE}.msg 2>&1
FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} \ FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} \
-check-prefix=CHECK-FIXES -strict-whitespace -check-prefix=CHECK-FIXES -strict-whitespace

View File

@ -1,21 +1,21 @@
// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-todo %t // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-todo %t -config="{User: 'some user'}" --
// REQUIRES: shell // REQUIRES: shell
// TODOfix this1 // TODOfix this1
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO // CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
// CHECK-FIXES: // TODO({{[^)]+}}): fix this1 // CHECK-FIXES: // TODO(some user): fix this1
// TODO fix this2 // TODO fix this2
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO // CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
// CHECK-FIXES: // TODO({{[^)]+}}): fix this2 // CHECK-FIXES: // TODO(some user): fix this2
// TODO fix this3 // TODO fix this3
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO // CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
// CHECK-FIXES: // TODO({{[^)]+}}): fix this3 // CHECK-FIXES: // TODO(some user): fix this3
// TODO: fix this4 // TODO: fix this4
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO // CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
// CHECK-FIXES: // TODO({{[^)]+}}): fix this4 // CHECK-FIXES: // TODO(some user): fix this4
// TODO(clang)fix this5 // TODO(clang)fix this5

View File

@ -1,4 +1,4 @@
// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-include-order %t -isystem %S/Inputs/Headers // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-include-order %t -- -isystem %S/Inputs/Headers
// REQUIRES: shell // REQUIRES: shell
// FIXME: Investigating. // FIXME: Investigating.