Skip to content

Commit c14e06b

Browse files
committed
fix
1 parent 6c96872 commit c14e06b

2 files changed

Lines changed: 4 additions & 34 deletions

File tree

lib/clangimport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ static std::vector<std::string> splitString(const std::string &line)
218218
}
219219

220220
static std::string getQualTypeBefore(const std::string& qualType) {
221-
return qualType.find("[") != std::string::npos ? qualType.substr(0, qualType.find("[")) : qualType;
221+
return qualType.find_first_of("[(") != std::string::npos ? qualType.substr(0, qualType.find_first_of("[(")) : qualType;
222222
}
223223

224224
static std::string getQualTypeAfter(const std::string& qualType) {
225-
return qualType.find("[") != std::string::npos ? qualType.substr(qualType.find("[")) : "";
225+
return qualType.find_first_of("[(") != std::string::npos ? qualType.substr(qualType.find_first_of("[(")) : "";
226226
}
227227

228228
namespace clangimport {

test/cli/clang-import_test.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -65,47 +65,36 @@ def __check_ast(tmpdir, code):
6565
assert __get_debug_section('##AST', stdout1) == __get_debug_section('##AST', stdout2)
6666

6767

68-
@pytest.mark.skip() # FIXME: broken when clang json support was added
6968
def test_symbol_database_1(tmpdir):
7069
__check_symbol_database(tmpdir, 'int main(){return 0;}')
7170

72-
@pytest.mark.skip() # FIXME: broken when clang json support was added
7371
def test_symbol_database_2(tmpdir):
7472
__check_symbol_database(tmpdir, 'struct Foo { void f(); }; void Foo::f() {}')
7573

76-
@pytest.mark.skip() # FIXME: broken when clang json support was added
7774
def test_symbol_database_3(tmpdir):
7875
__check_symbol_database(tmpdir, 'struct Fred { int a; }; int b; void f(int c, int d) { int e; }')
7976

80-
@pytest.mark.skip() # FIXME: broken when clang json support was added
8177
def test_symbol_database_4(tmpdir):
8278
__check_symbol_database(tmpdir, 'void f(const int x) {}')
8379

84-
@pytest.mark.skip() # FIXME: broken when clang json support was added
8580
def test_symbol_database_5(tmpdir):
8681
__check_symbol_database(tmpdir, 'void f(int);')
8782

88-
@pytest.mark.skip() # FIXME: broken when clang json support was added
8983
def test_symbol_database_6(tmpdir):
9084
__check_symbol_database(tmpdir, 'inline static int foo(int x) { return x; }')
9185

92-
@pytest.mark.skip() # FIXME: broken when clang json support was added
9386
def test_symbol_database_7(tmpdir):
9487
__check_symbol_database(tmpdir, 'struct S {int x;}; void f(struct S *s) {}')
9588

96-
@pytest.mark.skip() # FIXME: broken when clang json support was added
9789
def test_symbol_database_class_access_1(tmpdir):
9890
__check_symbol_database(tmpdir, 'class Fred { void foo ( ) {} } ;')
9991

100-
@pytest.mark.skip() # FIXME: broken when clang json support was added
10192
def test_symbol_database_class_access_2(tmpdir):
10293
__check_symbol_database(tmpdir, 'class Fred { protected: void foo ( ) {} } ;')
10394

104-
@pytest.mark.skip() # FIXME: broken when clang json support was added
10595
def test_symbol_database_class_access_3(tmpdir):
10696
__check_symbol_database(tmpdir, 'class Fred { public: void foo ( ) {} } ;')
10797

108-
@pytest.mark.skip() # FIXME: broken when clang json support was added
10998
def test_symbol_database_operator(tmpdir):
11099
__check_symbol_database(tmpdir, 'struct Fred { void operator=(int x); };')
111100

@@ -173,106 +162,88 @@ def __test_cmd(tmp_path, file_name, extra_args, stdout_exp_1, content=''):
173162
assert stderr == ''
174163
assert stdout.splitlines() == [
175164
'Checking {} ...'.format(file_name),
176-
'clang -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics {}{}'.format(stdout_exp_1, file_name)
165+
'clang -fsyntax-only -Xclang -ast-dump=json -fno-color-diagnostics {}{}'.format(stdout_exp_1, file_name)
177166
]
178167

179168

180-
@pytest.mark.skip() # FIXME: broken when clang json support was added
181169
def test_cmd_c(tmp_path):
182170
__test_cmd(tmp_path, 'test.c', [], '-x c')
183171

184172

185-
@pytest.mark.skip() # FIXME: broken when clang json support was added
186173
def test_cmd_cpp(tmp_path):
187174
__test_cmd(tmp_path, 'test.cpp', [], '-x c++')
188175

189176

190177
# files with unknown extensions are treated as C++
191-
@pytest.mark.skip() # FIXME: broken when clang json support was added
192178
def test_cmd_unk(tmp_path):
193179
__test_cmd(tmp_path, 'test.cplusplus', [], '-x c++')
194180

195181

196182
# headers are treated as C by default
197-
@pytest.mark.skip() # FIXME: broken when clang json support was added
198183
def test_cmd_hdr(tmp_path):
199184
__test_cmd(tmp_path, 'test.h', [], '-x c')
200185

201186

202-
@pytest.mark.skip() # FIXME: broken when clang json support was added
203187
def test_cmd_hdr_probe(tmp_path):
204188
__test_cmd(tmp_path, 'test.h', ['--cpp-header-probe'], '-x c++', '// -*- C++ -*-')
205189

206190

207-
@pytest.mark.skip() # FIXME: broken when clang json support was added
208191
def test_cmd_inc(tmp_path):
209192
inc_path = tmp_path / 'inc'
210193
os.makedirs(inc_path)
211194
__test_cmd(tmp_path, 'test.cpp',['-Iinc'], '-x c++ -Iinc/')
212195

213196

214-
@pytest.mark.skip() # FIXME: broken when clang json support was added
215197
def test_cmd_def(tmp_path):
216198
__test_cmd(tmp_path, 'test.cpp',['-DDEF'], '-x c++ -DDEF=1')
217199

218200

219-
@pytest.mark.skip() # FIXME: broken when clang json support was added
220201
def test_cmd_include(tmp_path):
221202
inc_file = tmp_path / 'inc.h'
222203
with open(inc_file, 'wt'):
223204
pass
224205
__test_cmd(tmp_path, 'test.cpp',['--include=inc.h'], '-x c++ --include inc.h')
225206

226207

227-
@pytest.mark.skip() # FIXME: broken when clang json support was added
228208
def test_cmd_enforce_c(tmp_path): # #13128
229209
__test_cmd(tmp_path, 'test.cpp',['-x', 'c'], '-x c')
230210

231211

232-
@pytest.mark.skip() # FIXME: broken when clang json support was added
233212
def test_cmd_enforce_cpp(tmp_path): # #13128
234213
__test_cmd(tmp_path, 'test.c',['-x', 'c++'], '-x c++')
235214

236215

237-
@pytest.mark.skip() # FIXME: broken when clang json support was added
238216
def test_cmd_std_c(tmp_path): # #13129
239217
__test_cmd(tmp_path, 'test.cpp',['--std=c89', '--std=c++14'], '-x c++ -std=c++14')
240218

241219

242220
# TODO: remove when we inject the build-dir into all tests
243-
@pytest.mark.skip() # FIXME: broken when clang json support was added
244221
def test_cmd_std_c_builddir(tmp_path): # #13129
245222
build_dir = tmp_path / 'b1'
246223
os.makedirs(build_dir)
247224
__test_cmd(tmp_path, 'test.cpp',['--std=c89', '--std=c++14', '--cppcheck-build-dir={}'.format(build_dir)], '-x c++ -std=c++14')
248225

249226

250-
@pytest.mark.skip() # FIXME: broken when clang json support was added
251227
def test_cmd_std_cpp(tmp_path): # #13129
252228
__test_cmd(tmp_path, 'test.c',['--std=c89', '--std=c++14'], '-x c -std=c89')
253229

254230

255-
@pytest.mark.skip() # FIXME: broken when clang json support was added
256231
def test_cmd_std_c_enforce(tmp_path): # #13128/#13129
257232
__test_cmd(tmp_path, 'test.cpp',['--language=c', '--std=c89', '--std=c++14'], '-x c -std=c89')
258233

259234

260-
@pytest.mark.skip() # FIXME: broken when clang json support was added
261235
def test_cmd_std_cpp_enforce(tmp_path): # #13128/#13129
262236
__test_cmd(tmp_path, 'test.c',['--language=c++', '--std=c89', '--std=c++14'], '-x c++ -std=c++14')
263237

264238

265-
@pytest.mark.skip() # FIXME: broken when clang json support was added
266239
def test_cmd_std_c_enforce_alias(tmp_path): # #13128/#13129/#13130
267240
__test_cmd(tmp_path, 'test.c',['--language=c', '--std=gnu99', '--std=gnu++11'], '-x c -std=gnu99')
268241

269242

270-
@pytest.mark.skip() # FIXME: broken when clang json support was added
271243
def test_cmd_std_c_enforce_alias_2(tmp_path): # #13128/#13129/#13130
272244
__test_cmd(tmp_path, 'test.c',['--language=c', '--std=iso9899:1999', '--std=gnu++11'], '-x c -std=iso9899:1999')
273245

274246

275-
@pytest.mark.skip() # FIXME: broken when clang json support was added
276247
def test_cmd_std_cpp_enforce_alias(tmp_path): # #13128/#13129/#13130
277248
__test_cmd(tmp_path, 'test.c',['--language=c++', '--std=gnu99', '--std=gnu++11'], '-x c++ -std=gnu++11')
278249

@@ -300,7 +271,6 @@ def test_debug_clang_output(tmp_path):
300271
assert stdout.find(str(test_file)) != -1, stdout
301272

302273

303-
@pytest.mark.skip() # FIXME: broken when clang json support was added
304274
def test_debug_clang_output_failure_exitcode(tmp_path):
305275
# the given code will cause clang to fail with an exitcode
306276
#
@@ -332,6 +302,6 @@ def test_debug_clang_output_failure_exitcode(tmp_path):
332302
stderr_lines = stderr.splitlines()
333303
assert len(stderr_lines) > 5, stderr_lines
334304
assert (stderr_lines[0] ==
335-
"Failed to execute 'clang -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics -x c {} 2>&1' - (exitcode: 1 / output: {}:3:12: error: indirection requires pointer operand ('int' invalid)".format(test_file, test_file))
305+
"Failed to execute 'clang -fsyntax-only -Xclang -ast-dump=json -fno-color-diagnostics -x c {} 2>&1' - (exitcode: 1 / output: {}:3:12: error: indirection requires pointer operand ('int' invalid)".format(test_file, test_file))
336306
assert stdout.find('TranslationUnitDecl') != -1, stdout
337307
assert stdout.find(str(test_file)) != -1, stdout

0 commit comments

Comments
 (0)