Clang import: Fix Variable::isRValueReference
This commit is contained in:
parent
970beaa79a
commit
5cfe2e319c
|
@ -1848,6 +1848,8 @@ Variable::Variable(const Token *name_, const std::string &clangType, const Token
|
|||
|
||||
if (endsWith(clangType, " &", 2))
|
||||
setFlag(fIsReference, true);
|
||||
else if (endsWith(clangType, " &&", 3))
|
||||
setFlag(fIsRValueRef, true);
|
||||
|
||||
std::string::size_type pos = clangType.find("[");
|
||||
if (pos != std::string::npos) {
|
||||
|
|
|
@ -108,6 +108,7 @@ private:
|
|||
TEST_CASE(symbolDatabaseFunction3);
|
||||
TEST_CASE(symbolDatabaseFunctionConst);
|
||||
TEST_CASE(symbolDatabaseVariableRef);
|
||||
TEST_CASE(symbolDatabaseVariableRRef);
|
||||
TEST_CASE(symbolDatabaseNodeType1);
|
||||
|
||||
TEST_CASE(valueFlow1);
|
||||
|
@ -1072,6 +1073,27 @@ private:
|
|||
ASSERT(refVar->isReference());
|
||||
}
|
||||
|
||||
void symbolDatabaseVariableRRef() {
|
||||
const char clang[] = "`-FunctionDecl 0x1a40df0 <3.cpp:1:1, line:4:1> line:1:6 foo 'void ()'\n"
|
||||
" `-CompoundStmt 0x1a41180 <col:12, line:4:1>\n"
|
||||
" |-DeclStmt 0x1a40f58 <line:2:3, col:8>\n"
|
||||
" | `-VarDecl 0x1a40ef0 <col:3, col:7> col:7 used x 'int'\n"
|
||||
" `-DeclStmt 0x1a41168 <line:3:3, col:18>\n"
|
||||
" `-VarDecl 0x1a40fb8 <col:3, col:17> col:9 ref 'int &&' cinit\n"
|
||||
" `-ExprWithCleanups 0x1a410f8 <col:15, col:17> 'int' xvalue\n"
|
||||
" `-MaterializeTemporaryExpr 0x1a41098 <col:15, col:17> 'int' xvalue extended by Var 0x1a40fb8 'ref' 'int &&'\n"
|
||||
" `-BinaryOperator 0x1a41078 <col:15, col:17> 'int' '+'\n"
|
||||
" |-ImplicitCastExpr 0x1a41060 <col:15> 'int' <LValueToRValue>\n"
|
||||
" | `-DeclRefExpr 0x1a41020 <col:15> 'int' lvalue Var 0x1a40ef0 'x' 'int'\n"
|
||||
" `-IntegerLiteral 0x1a41040 <col:17> 'int' 1\n";
|
||||
|
||||
ASSERT_EQUALS("void foo ( ) { int x@1 ; int && ref@2 = x@1 + 1 ; }", parse(clang));
|
||||
|
||||
GET_SYMBOL_DB(clang);
|
||||
const Variable *refVar = db->variableList().back();
|
||||
ASSERT(refVar->isRValueReference());
|
||||
}
|
||||
|
||||
void symbolDatabaseNodeType1() {
|
||||
const char clang[] = "`-FunctionDecl 0x32438c0 <line:5:1, line:7:1> line:5:6 foo 'a::b (a::b)'\n"
|
||||
" |-ParmVarDecl 0x32437b0 <col:10, col:15> col:15 used i 'a::b':'long'\n"
|
||||
|
|
Loading…
Reference in New Issue