MCPcopy Create free account
hub / github.com/KDE/kdevelop / isDereferenceOrAddressOf

Method isDereferenceOrAddressOf

plugins/astyle/3rdparty/libastyle/ASFormatter.cpp:3313–3388  ·  view source on GitHub ↗

* Check if the currently reached '*' or '&' character is * a dereferenced pointer or "address of" symbol. * NOTE: this MUST be a pointer or reference as determined by * the function isPointerOrReference(). * * @return whether current character is a dereference or address of */

Source from the content-addressed store, hash-verified

3311 * @return whether current character is a dereference or address of
3312 */
3313bool ASFormatter::isDereferenceOrAddressOf() const
3314{
3315 assert(currentChar == '*' || currentChar == '&' || currentChar == '^');
3316
3317 if (isCharImmediatelyPostTemplate)
3318 return false;
3319
3320 if (previousNonWSChar == '='
3321 || previousNonWSChar == ','
3322 || previousNonWSChar == '.'
3323 || previousNonWSChar == '{'
3324 || previousNonWSChar == '>'
3325 || previousNonWSChar == '<'
3326 || previousNonWSChar == '?'
3327 || isCharImmediatelyPostLineComment
3328 || isCharImmediatelyPostComment
3329 || isCharImmediatelyPostReturn)
3330 return true;
3331
3332 char nextChar = peekNextChar();
3333 if (currentChar == '*' && nextChar == '*')
3334 {
3335 if (previousNonWSChar == '(')
3336 return true;
3337 if ((int) currentLine.length() < charNum + 2)
3338 return true;
3339 return false;
3340 }
3341 if (currentChar == '&' && nextChar == '&')
3342 {
3343 if (previousNonWSChar == '(' || isInTemplate)
3344 return true;
3345 if ((int) currentLine.length() < charNum + 2)
3346 return true;
3347 return false;
3348 }
3349
3350 // check first char on the line
3351 if (charNum == (int) currentLine.find_first_not_of(" \t")
3352 && (isBraceType(braceTypeStack->back(), COMMAND_TYPE)
3353 || parenStack->back() != 0))
3354 return true;
3355
3356 string nextText = peekNextText(currentLine.substr(charNum + 1));
3357 if (nextText.length() > 0)
3358 {
3359 if (nextText[0] == ')' || nextText[0] == '>'
3360 || nextText[0] == ',' || nextText[0] == '=')
3361 return false;
3362 if (nextText[0] == ';')
3363 return true;
3364 }
3365
3366 // check for reference to a pointer *&
3367 if ((currentChar == '*' && nextChar == '&')
3368 || (previousNonWSChar == '*' && currentChar == '&'))
3369 return false;
3370

Callers

nothing calls this directly

Calls 3

substrMethod · 0.80
lengthMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected