//===--- MacroArgs.cpp - Formal argument info for Macros ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the MacroArgs interface. // //===----------------------------------------------------------------------===// #include "clang/Lex/MacroArgs.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/MacroInfo.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/SaveAndRestore.h" #include <algorithm> usingnamespaceclang; /// MacroArgs ctor function - This destroys the vector passed in. MacroArgs *MacroArgs::create(const MacroInfo *MI, ArrayRef<Token> UnexpArgTokens, bool VarargsElided, Preprocessor &PP) { … } /// destroy - Destroy and deallocate the memory for this object. /// void MacroArgs::destroy(Preprocessor &PP) { … } /// deallocate - This should only be called by the Preprocessor when managing /// its freelist. MacroArgs *MacroArgs::deallocate() { … } /// getArgLength - Given a pointer to an expanded or unexpanded argument, /// return the number of tokens, not counting the EOF, that make up the /// argument. unsigned MacroArgs::getArgLength(const Token *ArgPtr) { … } /// getUnexpArgument - Return the unexpanded tokens for the specified formal. /// const Token *MacroArgs::getUnexpArgument(unsigned Arg) const { … } bool MacroArgs::invokedWithVariadicArgument(const MacroInfo *const MI, Preprocessor &PP) { … } /// ArgNeedsPreexpansion - If we can prove that the argument won't be affected /// by pre-expansion, return false. Otherwise, conservatively return true. bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok, Preprocessor &PP) const { … } /// getPreExpArgument - Return the pre-expanded form of the specified /// argument. const std::vector<Token> &MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) { … } /// StringifyArgument - Implement C99 6.10.3.2p2, converting a sequence of /// tokens into the literal string token that should be produced by the C # /// preprocessor operator. If Charify is true, then it should be turned into /// a character literal for the Microsoft charize (#@) extension. /// Token MacroArgs::StringifyArgument(const Token *ArgToks, Preprocessor &PP, bool Charify, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd) { … }