Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 43 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
dist: trusty
language: cpp
sudo: false

matrix:
include:
- env: BUILD_TYPE=debug
- env: BUILD_TYPE=release
- env: BUILD_TYPE=release NO_MACRO_VARARG=1
- os: linux
dist: trusty
env: BUILD_TYPE=debug
- os: linux
dist: trusty
env: BUILD_TYPE=release
- os: linux
dist: trusty
env: BUILD_TYPE=release NO_MACRO_VARARG=1

# GCC 5
- env: C_COMPILER=gcc-5 CXX_COMPILER=g++-5
# GCC 6
- os: linux
dist: trusty
env: C_COMPILER=gcc-6 CXX_COMPILER=g++-6
addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-5
- g++-5
- gcc-6
- g++-6

# Clang 3.8 address sanitizer
- env: BUILD_TYPE=asan C_COMPILER=clang-3.8 CXX_COMPILER=clang++-3.8
- os: linux
dist: trusty
env: BUILD_TYPE=asan C_COMPILER=clang-3.8 CXX_COMPILER=clang++-3.8
addons:
apt:
sources:
Expand All @@ -30,7 +39,9 @@ matrix:
- clang-3.8

# mingw-w64 Win64 cross-compile
- env: BUILD_TYPE=cross C_COMPILER=x86_64-w64-mingw32-gcc CXX_COMPILER=x86_64-w64-mingw32-g++
- os: linux
dist: trusty
env: BUILD_TYPE=cross C_COMPILER=x86_64-w64-mingw32-gcc CXX_COMPILER=x86_64-w64-mingw32-g++
addons:
apt:
packages:
Expand All @@ -45,9 +56,17 @@ matrix:
- g++-mingw-w64-i686
- g++-mingw-w64-x86-64

- env: BUILD_TYPE=coverage COVERALLS_TOKEN="iJXKQxvt6RJMcxkn99GIhakcoCx7XvzbU"
- os: linux
dist: trusty
env: BUILD_TYPE=coverage COVERALLS_TOKEN="iJXKQxvt6RJMcxkn99GIhakcoCx7XvzbU"
compiler: gcc

# OSX
- os: osx
env: BUILD_TYPE=debug
- os: osx
env: BUILD_TYPE=release

branches:
only:
- master
Expand All @@ -70,6 +89,14 @@ before_install:
before_script:
# to stop the script after an error/warning
- set -e
# workarounds for OSX traivs build failure issues:
# 1. rvm overrides cd with a function so that it can hook into it to run some scripts from the new
# working directory. The workaround is to revert it to the builtin shell one.
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then unset -f cd; fi
# 2. Redefine shell_session_update as a dummy function to avoid travis error:
# /Users/travis/.rvm/scripts/functions/support: line 57: shell_session_update: command not found.
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then shell_session_update() { :; }; fi
# prepare make files with cmake
- |-
case "${BUILD_TYPE}" in
"coverage")
Expand All @@ -94,13 +121,16 @@ before_script:


script:
# build
- make VERBOSE=1
- if [ "x${BUILD_TYPE}" != "xcross" ]; then ctest -V -j 4; fi
- if [ "x${BUILD_TYPE}" == "xcoverage" ]; then make coverage; fi
# test if all the sources are conform to the forUncrustifySources.cfg config file
# test if all the sources are conform to the forUncrustifySources.cfg config file
- if [ "x${BUILD_TYPE}" == "xrelease" ]; then cd ../ && ./scripts/Run_uncrustify_for_sources.sh; cd -; fi
# test if uncrustify runs for (some) command line options
# test if uncrustify runs for (some) command line options
- if [ "x${BUILD_TYPE}" == "xrelease" ]; then cd ../tests/cli && ./test_cli_options.py; cd -; fi

# DO NOT REMOVE (debugging purposes)
#- /home/travis/build/uncrustify/uncrustify/build/uncrustify -l cs -c /home/travis/build/uncrustify/uncrustify/tests/config/U10-Cpp.cfg -f /home/travis/build/uncrustify/uncrustify/tests/input/cs/newlines.mm -L A

after_success:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Travis CI](https://img.shields.io/travis/Unity-Technologies/uncrustify/master.svg?style=flat-square&label=Linux)](https://travis-ci.org/Unity-Technologies/uncrustify)
[![AppVeyor](https://img.shields.io/appveyor/ci/henriksunity/uncrustify/master.svg?style=flat-square&label=Windows)](https://ci.appveyor.com/project/henriksunity/uncrustify)
[![Coverity](https://scan.coverity.com/projects/8264/badge.svg)](https://scan.coverity.com/projects/uncrustify)
[![Coverage Status](https://coveralls.io/repos/github/Unity-Technologies/uncrustify/badge.svg?branch=master)](https://coveralls.io/github/Unity-Technologies/uncrustify?branch=master)
<a href="#"><img src="https://img.shields.io/badge/C++-11-blue.svg?style=flat-square"></a>
[![Coverage Status](https://coveralls.io/repos/github/Unity-Technologies/uncrustify/badge.svg?branch=ci-cd%2Fcoveralls)](https://coveralls.io/github/Unity-Technologies/uncrustify?branch=ci-cd%2Fcoveralls)

---------------------------

Expand Down
27 changes: 20 additions & 7 deletions src/tokenize_cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,8 @@ static void check_template(chunk_t *start)
LOG_FMT(LTEMPL, "%s(%d): CT_TEMPLATE:\n", __func__, __LINE__);

// We have: "template< ... >", which is a template declaration
size_t level = 1;
size_t level = 1;
size_t parens = 0;
for (pc = chunk_get_next_ncnl(start, scope_e::PREPROC);
pc != nullptr;
pc = chunk_get_next_ncnl(pc, scope_e::PREPROC))
Expand All @@ -1022,16 +1023,28 @@ static void check_template(chunk_t *start)
split_off_angle_close(pc);
}

if (chunk_is_str(pc, "<", 1))
if (pc->type == CT_PAREN_OPEN)
{
level++;
++parens;
}
else if (chunk_is_str(pc, ">", 1))
else if (pc->type == CT_PAREN_CLOSE)
{
--parens;
}

if (parens == 0)
{
level--;
if (level == 0)
if (chunk_is_str(pc, "<", 1))
{
break;
level++;
}
else if (chunk_is_str(pc, ">", 1))
{
level--;
if (level == 0)
{
break;
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8)

find_package(Git QUIET)

function(add_uncrustify_test name lang config rerun_config input result result_2 output rerun_output)
add_test(NAME ${name}
COMMAND ${CMAKE_COMMAND}
Expand All @@ -13,6 +15,7 @@ function(add_uncrustify_test name lang config rerun_config input result result_2
-DTEST_OUTPUT=${output}
-DTEST_RERUN_OUTPUT=${rerun_output}
-DTEST_DIR=${PROJECT_SOURCE_DIR}/tests
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-P ${PROJECT_SOURCE_DIR}/tests/run_test.cmake
)
set_tests_properties(${name}
Expand Down
2 changes: 2 additions & 0 deletions tests/cpp.test
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
30111 indent_columns-4.cfg cpp/bug_1346.h
30112 bug_1432.cfg cpp/bug_1432.cpp
30113 bug_1452.cfg cpp/bug_1452.cpp
30114 empty.cfg cpp/bug_1462.cpp

30201 cmt_indent-1.cfg cpp/cmt_indent.cpp
30202 cmt_indent-2.cfg cpp/cmt_indent.cpp
Expand Down Expand Up @@ -606,6 +607,7 @@
10566 empty.cfg cpp/issue_1752.cpp
11000 UNI-12046.cfg cpp/UNI-12046.cpp
20002 UNI-32657.cfg cpp/UNI-32657.cpp
20011 empty.cfg cpp/UNI-38381.cpp
60001 UNI-2650.cfg cpp/UNI-2650.cpp
60002 U25-Cpp.cfg cpp/UNI-16283.cpp
60003 U26-Cpp.cfg cpp/UNI-1288.cpp
Expand Down
5 changes: 5 additions & 0 deletions tests/input/cpp/UNI-38381.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if UNITY_DEFER_GRAPHICS_JOBS_SCHEDULE
void GfxDevice::ScheduleAsyncJob(AsyncCommandJobFunc* jobFunc, GfxDeviceAsyncCommand* cmd, const JobFence& depends, JobBatchDispatcher& dispatcher)
#else
JobFence& GfxDevice::ScheduleAsyncJob(AsyncCommandJobFunc* jobFunc, GfxDeviceAsyncCommand* cmd, const JobFence& depends, JobBatchDispatcher& dispatcher)
#endif // #if UNITY_DEFER_GRAPHICS_JOBS_SCHEDULE
26 changes: 26 additions & 0 deletions tests/input/cpp/bug_1462.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <type_traits>

template <
typename... Args,
typename E = typename std::enable_if<(sizeof...(Args) >= 1), bool>::type
>
void fun1(Args&& ...args)
{
}

template <
typename... Args,
typename E = typename std::enable_if<(sizeof...(Args) > 1), bool>::type
>
void fun2(Args&& ...args)
{
}

template <
typename... Args,
typename E = typename std::enable_if<(sizeof...(Args) < 3), bool>::type
>
void fun3(Args&& ...args)
{
}

5 changes: 5 additions & 0 deletions tests/output/cpp/20011-UNI-38381.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if UNITY_DEFER_GRAPHICS_JOBS_SCHEDULE
void GfxDevice::ScheduleAsyncJob(AsyncCommandJobFunc* jobFunc, GfxDeviceAsyncCommand* cmd, const JobFence& depends, JobBatchDispatcher& dispatcher)
#else
JobFence& GfxDevice::ScheduleAsyncJob(AsyncCommandJobFunc* jobFunc, GfxDeviceAsyncCommand* cmd, const JobFence& depends, JobBatchDispatcher& dispatcher)
#endif // #if UNITY_DEFER_GRAPHICS_JOBS_SCHEDULE
26 changes: 26 additions & 0 deletions tests/output/cpp/30114-bug_1462.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <type_traits>

template <
typename ... Args,
typename E = typename std::enable_if<(sizeof ... (Args) > = 1), bool>::type
>
void fun1(Args&& ... args)
{
}

template <
typename ... Args,
typename E = typename std::enable_if<(sizeof ... (Args) > 1), bool>::type
>
void fun2(Args&& ... args)
{
}

template <
typename ... Args,
typename E = typename std::enable_if<(sizeof ... (Args) < 3), bool>::type
>
void fun3(Args&& ... args)
{
}

Loading