Use Library information in Tokenizer::sizeOfType()
This commit is contained in:
parent
da6b17d176
commit
3f255e7685
|
@ -138,9 +138,13 @@ unsigned int Tokenizer::sizeOfType(const Token *type) const
|
||||||
return Token::getStrLength(type) + 1U;
|
return Token::getStrLength(type) + 1U;
|
||||||
|
|
||||||
std::map<std::string, unsigned int>::const_iterator it = _typeSize.find(type->str());
|
std::map<std::string, unsigned int>::const_iterator it = _typeSize.find(type->str());
|
||||||
if (it == _typeSize.end())
|
if (it == _typeSize.end()) {
|
||||||
return 0;
|
const Library::PodType* podtype = _settings->library.podtype(type->str());
|
||||||
else if (type->isLong()) {
|
if (!podtype)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return podtype->size;
|
||||||
|
} else if (type->isLong()) {
|
||||||
if (type->str() == "double")
|
if (type->str() == "double")
|
||||||
return _settings->sizeof_long_double;
|
return _settings->sizeof_long_double;
|
||||||
else if (type->str() == "long")
|
else if (type->str() == "long")
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
TEST_CASE(sizeof19); // #1891 - sizeof 'x'
|
TEST_CASE(sizeof19); // #1891 - sizeof 'x'
|
||||||
TEST_CASE(sizeof20); // #2024 - sizeof a)
|
TEST_CASE(sizeof20); // #2024 - sizeof a)
|
||||||
TEST_CASE(sizeof21); // #2232 - sizeof...(Args)
|
TEST_CASE(sizeof21); // #2232 - sizeof...(Args)
|
||||||
|
TEST_CASE(sizeof22);
|
||||||
TEST_CASE(sizeofsizeof);
|
TEST_CASE(sizeofsizeof);
|
||||||
TEST_CASE(casting);
|
TEST_CASE(casting);
|
||||||
|
|
||||||
|
@ -1396,6 +1397,12 @@ private:
|
||||||
tok(code);
|
tok(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sizeof22() {
|
||||||
|
// sizeof from library
|
||||||
|
const char code[] = "foo(sizeof(uint32_t), sizeof(std::uint32_t));";
|
||||||
|
TODO_ASSERT_EQUALS("foo ( 4 , 4 ) ;", "foo ( 4 , sizeof ( std :: uint32_t ) ) ;", tokWithStdLib(code));
|
||||||
|
}
|
||||||
|
|
||||||
void sizeofsizeof() {
|
void sizeofsizeof() {
|
||||||
// ticket #1682
|
// ticket #1682
|
||||||
const char code[] = "void f()\n"
|
const char code[] = "void f()\n"
|
||||||
|
|
Loading…
Reference in New Issue