"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Lex/TokenConcatenation.cpp" between
cfe-8.0.1.src.tar.xz and cfe-9.0.0.src.tar.xz

About: Clang is an LLVM front end for the C, C++, and Objective-C languages. Clang aims to provide a better user experience through expressive diagnostics, a high level of conformance to language standards, fast compilation, and low memory use.

TokenConcatenation.cpp  (cfe-8.0.1.src.tar.xz):TokenConcatenation.cpp  (cfe-9.0.0.src.tar.xz)
//===--- TokenConcatenation.cpp - Token Concatenation Avoidance -----------===// //===--- TokenConcatenation.cpp - Token Concatenation Avoidance -----------===//
// //
// The LLVM Compiler Infrastructure // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// // See https://llvm.org/LICENSE.txt for license information.
// This file is distributed under the University of Illinois Open Source // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements the TokenConcatenation class. // This file implements the TokenConcatenation class.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "clang/Lex/TokenConcatenation.h" #include "clang/Lex/TokenConcatenation.h"
#include "clang/Basic/CharInfo.h" #include "clang/Basic/CharInfo.h"
#include "clang/Lex/Preprocessor.h" #include "clang/Lex/Preprocessor.h"
skipping to change at line 163 skipping to change at line 162
/// directly would. /// directly would.
/// ///
/// This code must conservatively return true if it doesn't want to be 100% /// This code must conservatively return true if it doesn't want to be 100%
/// accurate. This will cause the output to include extra space characters, /// accurate. This will cause the output to include extra space characters,
/// but the resulting output won't have incorrect concatenations going on. /// but the resulting output won't have incorrect concatenations going on.
/// Examples include "..", which we print with a space between, because we /// Examples include "..", which we print with a space between, because we
/// don't want to track enough to tell "x.." from "...". /// don't want to track enough to tell "x.." from "...".
bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok, bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok,
const Token &PrevTok, const Token &PrevTok,
const Token &Tok) const { const Token &Tok) const {
// Conservatively assume that every annotation token that has a printable
// form requires whitespace.
if (PrevTok.isAnnotation())
return true;
// First, check to see if the tokens were directly adjacent in the original // First, check to see if the tokens were directly adjacent in the original
// source. If they were, it must be okay to stick them together: if there // source. If they were, it must be okay to stick them together: if there
// were an issue, the tokens would have been lexed differently. // were an issue, the tokens would have been lexed differently.
SourceManager &SM = PP.getSourceManager(); SourceManager &SM = PP.getSourceManager();
SourceLocation PrevSpellLoc = SM.getSpellingLoc(PrevTok.getLocation()); SourceLocation PrevSpellLoc = SM.getSpellingLoc(PrevTok.getLocation());
SourceLocation SpellLoc = SM.getSpellingLoc(Tok.getLocation()); SourceLocation SpellLoc = SM.getSpellingLoc(Tok.getLocation());
if (PrevSpellLoc.getLocWithOffset(PrevTok.getLength()) == SpellLoc) if (PrevSpellLoc.getLocWithOffset(PrevTok.getLength()) == SpellLoc)
return false; return false;
tok::TokenKind PrevKind = PrevTok.getKind(); tok::TokenKind PrevKind = PrevTok.getKind();
 End of changes. 2 change blocks. 
4 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)