//===--- SemaChecking.cpp - Extra Semantic Checking -----------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file implements extra semantic analysis beyond what is enforced // by the C type system.////===----------------------------------------------------------------------===//#include"Sema.h"#include"clang/AST/ASTContext.h"#include"clang/AST/DeclObjC.h"#include"clang/AST/ExprCXX.h"#include"clang/AST/ExprObjC.h"#include"clang/Lex/LiteralSupport.h"#include"clang/Lex/Preprocessor.h"#include<limits>usingnamespaceclang;/// getLocationOfStringLiteralByte - Return a source location that points to the/// specified byte of the specified string literal.////// Strings are amazingly complex. They can be formed from multiple tokens and/// can have escape sequences in them in addition to the usual trigraph and/// escaped newline business. This routine handles this complexity.///SourceLocationSema::getLocationOfStringLiteralByte(constStringLiteral*SL,unsignedByteNo)const{assert(!SL->isWide()&&"This doesn't work for wide strings yet");// Loop over all of the tokens in this string until we find the one that// contains the byte we're looking for.unsignedTokNo=0;while(1){assert(TokNo<SL->getNumConcatenated()&&"Invalid byte number!");SourceLocationStrTokLoc=SL->getStrTokenLoc(TokNo);// Get the spelling of the string so that we can get the data that makes up// the string literal, not the identifier for the macro it is potentially// expanded through.SourceLocationStrTokSpellingLoc=SourceMgr.getSpellingLoc(StrTokLoc);// Re-lex the token to get its length and original spelling.std::pair<FileID,unsigned>LocInfo=SourceMgr.getDecomposedLoc(StrTokSpellingLoc);std::pair<constchar*,constchar*>Buffer=SourceMgr.getBufferData(LocInfo.first);constchar*StrData