summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpppreprocessor.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@digia.com>2013-10-22 11:24:29 +0200
committerNikolai Kosjar <nikolai.kosjar@digia.com>2013-10-23 10:46:14 +0200
commit1a5c7d8ef58660da8125ee78014d6e05fd55c1a9 (patch)
tree9d207bdc6a4400fa28138dedf8804d0235db69b0 /src/plugins/cpptools/cpppreprocessor.cpp
parent2448cab1c401f8a2c63f24b99dce95a066f007ef (diff)
downloadqt-creator-1a5c7d8ef58660da8125ee78014d6e05fd55c1a9.tar.gz
C++: Safe accessing of elements of TranslationUnit::_tokens
Until now std::vector::at() was used to access the elements. This is handy for debugging since an exception is thrown for invalid indices, but it does not stop Qt Creator from crashing because exceptions are not caught. This is especially a problem for the parser, which has to look ahead via LA(n), which accesses TranslationUnit::_tokens. With this patch, explicit bounds checking is done before accessing the elements and thus calls to std::vector::at() // bounds checking, throwing out_of_range were replaced by calls to std::vector::operator[]() // no bounds checking, not throwing out_of_range Measuring the parse time for the Qt Creator project shows that there is no slowdown. In both cases, with and without the patch, about 15s are needed on the authors machine. Task-number: QTCREATORBUG-10453 Change-Id: I32b12a526ff7199bcadfc21a3deb5354063a3e3b Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cpppreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions