diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -157,17 +157,6 @@ } // end of anonymous namespace -namespace { - -struct ExpansionInfo { - std::string MacroName; - std::string Expansion; - ExpansionInfo(std::string N, std::string E) - : MacroName(std::move(N)), Expansion(std::move(E)) {} -}; - -} // end of anonymous namespace - /// Print coverage information to output stream {@code o}. /// May modify the used list of files {@code Fids} by inserting new ones. static void printCoverage(const PathDiagnostic *D, @@ -176,9 +165,9 @@ FIDMap &FM, llvm::raw_fd_ostream &o); -static ExpansionInfo -getExpandedMacro(SourceLocation MacroLoc, const Preprocessor &PP, - const cross_tu::CrossTranslationUnitContext &CTU); +static MacroExpansionContext::MacroExpansionText getExpandedMacro( + SourceLocation MacroLoc, const cross_tu::CrossTranslationUnitContext &CTU, + const MacroExpansionContext &MacroExpansions, const SourceManager &SM); //===----------------------------------------------------------------------===// // Methods of PlistPrinter. @@ -391,7 +380,15 @@ for (const PathDiagnosticMacroPiece *P : MacroPieces) { const SourceManager &SM = PP.getSourceManager(); - ExpansionInfo EI = getExpandedMacro(P->getLocation().asLocation(), PP, CTU); + + SourceLocation MacroExpansionLoc = + P->getLocation().asLocation().getExpansionLoc(); + + StringRef MacroName = + MacroExpansions.getSubstitutedTextForLocation(MacroExpansionLoc); + + const auto ExpansionText = + getExpandedMacro(MacroExpansionLoc, CTU, MacroExpansions, SM); Indent(o, indent) << "\n"; ++indent; @@ -408,11 +405,11 @@ // Output the macro name. Indent(o, indent) << "name"; - EmitString(o, EI.MacroName) << '\n'; + EmitString(o, MacroName) << '\n'; // Output what it expands into. Indent(o, indent) << "expansion"; - EmitString(o, EI.Expansion) << '\n'; + EmitString(o, ExpansionText) << '\n'; // Finish up. --indent; @@ -822,571 +819,18 @@ o << "\n\n"; } -//===----------------------------------------------------------------------===// -// Declarations of helper functions and data structures for expanding macros. -//===----------------------------------------------------------------------===// - -namespace { - -using ArgTokensTy = llvm::SmallVector; - -} // end of anonymous namespace - -LLVM_DUMP_METHOD static void dumpArgTokensToStream(llvm::raw_ostream &Out, - const Preprocessor &PP, - const ArgTokensTy &Toks); - -namespace { -/// Maps unexpanded macro parameters to expanded arguments. A macro argument may -/// need to expanded further when it is nested inside another macro. -class MacroParamMap : public std::map { -public: - void expandFromPrevMacro(const MacroParamMap &Super); - - LLVM_DUMP_METHOD void dump(const Preprocessor &PP) const { - dumpToStream(llvm::errs(), PP); - } - - LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out, - const Preprocessor &PP) const; -}; - -struct MacroExpansionInfo { - std::string Name; - const MacroInfo *MI = nullptr; - MacroParamMap ParamMap; - - MacroExpansionInfo(std::string N, const MacroInfo *MI, MacroParamMap M) - : Name(std::move(N)), MI(MI), ParamMap(std::move(M)) {} -}; - -class TokenPrinter { - llvm::raw_ostream &OS; - const Preprocessor &PP; - - Token PrevTok, PrevPrevTok; - TokenConcatenation ConcatInfo; - -public: - TokenPrinter(llvm::raw_ostream &OS, const Preprocessor &PP) - : OS(OS), PP(PP), ConcatInfo(PP) { - PrevTok.setKind(tok::unknown); - PrevPrevTok.setKind(tok::unknown); - } - - void printToken(const Token &Tok); -}; - -/// Wrapper around a Lexer object that can lex tokens one-by-one. Its possible -/// to "inject" a range of tokens into the stream, in which case the next token -/// is retrieved from the next element of the range, until the end of the range -/// is reached. -class TokenStream { -public: - TokenStream(SourceLocation ExpanLoc, const SourceManager &SM, - const LangOptions &LangOpts) - : ExpanLoc(ExpanLoc) { - FileID File; - unsigned Offset; - std::tie(File, Offset) = SM.getDecomposedLoc(ExpanLoc); - llvm::MemoryBufferRef MB = SM.getBufferOrFake(File); - const char *MacroNameTokenPos = MB.getBufferStart() + Offset; - - RawLexer = std::make_unique(SM.getLocForStartOfFile(File), LangOpts, - MB.getBufferStart(), MacroNameTokenPos, - MB.getBufferEnd()); - } - - void next(Token &Result) { - if (CurrTokenIt == TokenRange.end()) { - RawLexer->LexFromRawLexer(Result); - return; - } - Result = *CurrTokenIt; - CurrTokenIt++; - } - - void injectRange(const ArgTokensTy &Range) { - TokenRange = Range; - CurrTokenIt = TokenRange.begin(); - } - - std::unique_ptr RawLexer; - ArgTokensTy TokenRange; - ArgTokensTy::iterator CurrTokenIt = TokenRange.begin(); - SourceLocation ExpanLoc; -}; - -} // end of anonymous namespace - -/// The implementation method of getMacroExpansion: It prints the expansion of -/// a macro to \p Printer, and returns with the name of the macro. -/// -/// Since macros can be nested in one another, this function may call itself -/// recursively. -/// -/// Unfortunately, macro arguments have to expanded manually. To understand why, -/// observe the following example: -/// -/// #define PRINT(x) print(x) -/// #define DO_SOMETHING(str) PRINT(str) -/// -/// DO_SOMETHING("Cute panda cubs."); -/// -/// As we expand the last line, we'll immediately replace PRINT(str) with -/// print(x). The information that both 'str' and 'x' refers to the same string -/// is an information we have to forward, hence the argument \p PrevParamMap. -/// -/// To avoid infinite recursion we maintain the already processed tokens in -/// a set. This is carried as a parameter through the recursive calls. The set -/// is extended with the currently processed token and after processing it, the -/// token is removed. If the token is already in the set, then recursion stops: -/// -/// #define f(y) x -/// #define x f(x) -static std::string getMacroNameAndPrintExpansion( - TokenPrinter &Printer, SourceLocation MacroLoc, const Preprocessor &PP, - const MacroParamMap &PrevParamMap, - llvm::SmallPtrSet &AlreadyProcessedTokens); - -/// Retrieves the name of the macro and what it's parameters expand into -/// at \p ExpanLoc. -/// -/// For example, for the following macro expansion: -/// -/// #define SET_TO_NULL(x) x = 0 -/// #define NOT_SUSPICIOUS(a) \ -/// { \ -/// int b = 0; \ -/// } \ -/// SET_TO_NULL(a) -/// -/// int *ptr = new int(4); -/// NOT_SUSPICIOUS(&ptr); -/// *ptr = 5; -/// -/// When \p ExpanLoc references the last line, the macro name "NOT_SUSPICIOUS" -/// and the MacroArgMap map { (a, &ptr) } will be returned. -/// -/// When \p ExpanLoc references "SET_TO_NULL(a)" within the definition of -/// "NOT_SUSPICOUS", the macro name "SET_TO_NULL" and the MacroArgMap map -/// { (x, a) } will be returned. -static MacroExpansionInfo -getMacroExpansionInfo(const MacroParamMap &PrevParamMap, - SourceLocation ExpanLoc, const Preprocessor &PP); - -/// Retrieves the ')' token that matches '(' \p It points to. -static MacroInfo::tokens_iterator getMatchingRParen( - MacroInfo::tokens_iterator It, - MacroInfo::tokens_iterator End); - -/// Retrieves the macro info for \p II refers to at \p Loc. This is important -/// because macros can be redefined or undefined. -static const MacroInfo *getMacroInfoForLocation(const Preprocessor &PP, - const SourceManager &SM, - const IdentifierInfo *II, - SourceLocation Loc); - //===----------------------------------------------------------------------===// // Definitions of helper functions and methods for expanding macros. //===----------------------------------------------------------------------===// -static ExpansionInfo -getExpandedMacro(SourceLocation MacroLoc, const Preprocessor &PP, - const cross_tu::CrossTranslationUnitContext &CTU) { - - const Preprocessor *PPToUse = &PP; - if (auto LocAndUnit = CTU.getImportedFromSourceLocation(MacroLoc)) { - MacroLoc = LocAndUnit->first; - PPToUse = &LocAndUnit->second->getPreprocessor(); +static MacroExpansionContext::MacroExpansionText +getExpandedMacro(SourceLocation MacroExpansionLoc, + const cross_tu::CrossTranslationUnitContext &CTU, + const MacroExpansionContext &MacroExpansions, + const SourceManager &SM) { + if (auto LocAndUnit = CTU.getImportedFromSourceLocation(MacroExpansionLoc)) { + // TODO: Implement macro expansions for CTU. + return {""}; } - - llvm::SmallString<200> ExpansionBuf; - llvm::raw_svector_ostream OS(ExpansionBuf); - TokenPrinter Printer(OS, *PPToUse); - llvm::SmallPtrSet AlreadyProcessedTokens; - - std::string MacroName = getMacroNameAndPrintExpansion( - Printer, MacroLoc, *PPToUse, MacroParamMap{}, AlreadyProcessedTokens); - return {MacroName, std::string(OS.str())}; -} - -static std::string getMacroNameAndPrintExpansion( - TokenPrinter &Printer, SourceLocation MacroLoc, const Preprocessor &PP, - const MacroParamMap &PrevParamMap, - llvm::SmallPtrSet &AlreadyProcessedTokens) { - - const SourceManager &SM = PP.getSourceManager(); - - MacroExpansionInfo MExpInfo = - getMacroExpansionInfo(PrevParamMap, SM.getExpansionLoc(MacroLoc), PP); - IdentifierInfo *MacroNameII = PP.getIdentifierInfo(MExpInfo.Name); - - // TODO: If the macro definition contains another symbol then this function is - // called recursively. In case this symbol is the one being defined, it will - // be an infinite recursion which is stopped by this "if" statement. However, - // in this case we don't get the full expansion text in the Plist file. See - // the test file where "value" is expanded to "garbage_" instead of - // "garbage_value". - if (!AlreadyProcessedTokens.insert(MacroNameII).second) - return MExpInfo.Name; - - if (!MExpInfo.MI) - return MExpInfo.Name; - - // Manually expand its arguments from the previous macro. - MExpInfo.ParamMap.expandFromPrevMacro(PrevParamMap); - - // Iterate over the macro's tokens and stringify them. - for (auto It = MExpInfo.MI->tokens_begin(), E = MExpInfo.MI->tokens_end(); - It != E; ++It) { - Token T = *It; - - // If this token is not an identifier, we only need to print it. - if (T.isNot(tok::identifier)) { - Printer.printToken(T); - continue; - } - - const auto *II = T.getIdentifierInfo(); - assert(II && - "This token is an identifier but has no IdentifierInfo!"); - - // If this token is a macro that should be expanded inside the current - // macro. - if (getMacroInfoForLocation(PP, SM, II, T.getLocation())) { - getMacroNameAndPrintExpansion(Printer, T.getLocation(), PP, - MExpInfo.ParamMap, AlreadyProcessedTokens); - - // If this is a function-like macro, skip its arguments, as - // getExpandedMacro() already printed them. If this is the case, let's - // first jump to the '(' token. - auto N = std::next(It); - if (N != E && N->is(tok::l_paren)) - It = getMatchingRParen(++It, E); - continue; - } - - // If this token is the current macro's argument, we should expand it. - auto ParamToArgIt = MExpInfo.ParamMap.find(II); - if (ParamToArgIt != MExpInfo.ParamMap.end()) { - for (MacroInfo::tokens_iterator ArgIt = ParamToArgIt->second.begin(), - ArgEnd = ParamToArgIt->second.end(); - ArgIt != ArgEnd; ++ArgIt) { - - // These tokens may still be macros, if that is the case, handle it the - // same way we did above. - const auto *ArgII = ArgIt->getIdentifierInfo(); - if (!ArgII) { - Printer.printToken(*ArgIt); - continue; - } - - const auto *MI = PP.getMacroInfo(ArgII); - if (!MI) { - Printer.printToken(*ArgIt); - continue; - } - - getMacroNameAndPrintExpansion(Printer, ArgIt->getLocation(), PP, - MExpInfo.ParamMap, - AlreadyProcessedTokens); - // Peek the next token if it is a tok::l_paren. This way we can decide - // if this is the application or just a reference to a function maxro - // symbol: - // - // #define apply(f) ... - // #define func(x) ... - // apply(func) - // apply(func(42)) - auto N = std::next(ArgIt); - if (N != ArgEnd && N->is(tok::l_paren)) - ArgIt = getMatchingRParen(++ArgIt, ArgEnd); - } - continue; - } - - // If control reached here, then this token isn't a macro identifier, nor an - // unexpanded macro argument that we need to handle, print it. - Printer.printToken(T); - } - - AlreadyProcessedTokens.erase(MacroNameII); - - return MExpInfo.Name; -} - -static MacroExpansionInfo -getMacroExpansionInfo(const MacroParamMap &PrevParamMap, - SourceLocation ExpanLoc, const Preprocessor &PP) { - - const SourceManager &SM = PP.getSourceManager(); - const LangOptions &LangOpts = PP.getLangOpts(); - - // First, we create a Lexer to lex *at the expansion location* the tokens - // referring to the macro's name and its arguments. - TokenStream TStream(ExpanLoc, SM, LangOpts); - - // Acquire the macro's name. - Token TheTok; - TStream.next(TheTok); - - std::string MacroName = PP.getSpelling(TheTok); - - const auto *II = PP.getIdentifierInfo(MacroName); - assert(II && "Failed to acquire the IdentifierInfo for the macro!"); - - const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc); - // assert(MI && "The macro must've been defined at it's expansion location!"); - // - // We should always be able to obtain the MacroInfo in a given TU, but if - // we're running the analyzer with CTU, the Preprocessor won't contain the - // directive history (or anything for that matter) from another TU. - // TODO: assert when we're not running with CTU. - if (!MI) - return { MacroName, MI, {} }; - - // Acquire the macro's arguments at the expansion point. - // - // The rough idea here is to lex from the first left parentheses to the last - // right parentheses, and map the macro's parameter to what they will be - // expanded to. A macro argument may contain several token (like '3 + 4'), so - // we'll lex until we find a tok::comma or tok::r_paren, at which point we - // start lexing the next argument or finish. - ArrayRef MacroParams = MI->params(); - if (MacroParams.empty()) - return { MacroName, MI, {} }; - - TStream.next(TheTok); - // When this is a token which expands to another macro function then its - // parentheses are not at its expansion locaiton. For example: - // - // #define foo(x) int bar() { return x; } - // #define apply_zero(f) f(0) - // apply_zero(foo) - // ^ - // This is not a tok::l_paren, but foo is a function. - if (TheTok.isNot(tok::l_paren)) - return { MacroName, MI, {} }; - - MacroParamMap ParamMap; - - // When the argument is a function call, like - // CALL_FN(someFunctionName(param1, param2)) - // we will find tok::l_paren, tok::r_paren, and tok::comma that do not divide - // actual macro arguments, or do not represent the macro argument's closing - // parentheses, so we'll count how many parentheses aren't closed yet. - // If ParanthesesDepth - // * = 0, then there are no more arguments to lex. - // * = 1, then if we find a tok::comma, we can start lexing the next arg. - // * > 1, then tok::comma is a part of the current arg. - int ParenthesesDepth = 1; - - // If we encounter the variadic arg, we will lex until the closing - // tok::r_paren, even if we lex a tok::comma and ParanthesesDepth == 1. - const IdentifierInfo *VariadicParamII = PP.getIdentifierInfo("__VA_ARGS__"); - if (MI->isGNUVarargs()) { - // If macro uses GNU-style variadic args, the param name is user-supplied, - // an not "__VA_ARGS__". E.g.: - // #define FOO(a, b, myvargs...) - // In this case, just use the last parameter: - VariadicParamII = *(MacroParams.rbegin()); - } - - for (const IdentifierInfo *CurrParamII : MacroParams) { - MacroParamMap::mapped_type ArgTokens; - - // One could also simply not supply a single argument to __VA_ARGS__ -- this - // results in a preprocessor warning, but is not an error: - // #define VARIADIC(ptr, ...) \ - // someVariadicTemplateFunction(__VA_ARGS__) - // - // int *ptr; - // VARIADIC(ptr); // Note that there are no commas, this isn't just an - // // empty parameter -- there are no parameters for '...'. - // In any other case, ParenthesesDepth mustn't be 0 here. - if (ParenthesesDepth != 0) { - - // Lex the first token of the next macro parameter. - TStream.next(TheTok); - - while (CurrParamII == VariadicParamII || ParenthesesDepth != 1 || - !TheTok.is(tok::comma)) { - assert(TheTok.isNot(tok::eof) && - "EOF encountered while looking for expanded macro args!"); - - if (TheTok.is(tok::l_paren)) - ++ParenthesesDepth; - - if (TheTok.is(tok::r_paren)) - --ParenthesesDepth; - - if (ParenthesesDepth == 0) - break; - - if (TheTok.is(tok::raw_identifier)) { - PP.LookUpIdentifierInfo(TheTok); - // This token is a variadic parameter: - // - // #define PARAMS_RESOLVE_TO_VA_ARGS(i, fmt) foo(i, fmt); \ - // i = 0; - // #define DISPATCH(...) \ - // PARAMS_RESOLVE_TO_VA_ARGS(__VA_ARGS__); - // // ^~~~~~~~~~~ Variadic parameter here - // - // void multipleParamsResolveToVA_ARGS(void) { - // int x = 1; - // DISPATCH(x, "LF1M healer"); // Multiple arguments are mapped to - // // a single __VA_ARGS__ parameter. - // (void)(10 / x); - // } - // - // We will stumble across this while trying to expand - // PARAMS_RESOLVE_TO_VA_ARGS. By this point, we already noted during - // the processing of DISPATCH what __VA_ARGS__ maps to, so we'll - // retrieve the next series of tokens from that. - if (TheTok.getIdentifierInfo() == VariadicParamII) { - TStream.injectRange(PrevParamMap.at(VariadicParamII)); - TStream.next(TheTok); - continue; - } - } - - ArgTokens.push_back(TheTok); - TStream.next(TheTok); - } - } else { - assert(CurrParamII == VariadicParamII && - "No more macro arguments are found, but the current parameter " - "isn't the variadic arg!"); - } - - ParamMap.emplace(CurrParamII, std::move(ArgTokens)); - } - - assert(TheTok.is(tok::r_paren) && - "Expanded macro argument acquisition failed! After the end of the loop" - " this token should be ')'!"); - - return {MacroName, MI, ParamMap}; -} - -static MacroInfo::tokens_iterator getMatchingRParen( - MacroInfo::tokens_iterator It, - MacroInfo::tokens_iterator End) { - - assert(It->is(tok::l_paren) && "This token should be '('!"); - - // Skip until we find the closing ')'. - int ParenthesesDepth = 1; - while (ParenthesesDepth != 0) { - ++It; - - assert(It->isNot(tok::eof) && - "Encountered EOF while attempting to skip macro arguments!"); - assert(It != End && - "End of the macro definition reached before finding ')'!"); - - if (It->is(tok::l_paren)) - ++ParenthesesDepth; - - if (It->is(tok::r_paren)) - --ParenthesesDepth; - } - return It; -} - -static const MacroInfo *getMacroInfoForLocation(const Preprocessor &PP, - const SourceManager &SM, - const IdentifierInfo *II, - SourceLocation Loc) { - - const MacroDirective *MD = PP.getLocalMacroDirectiveHistory(II); - if (!MD) - return nullptr; - - return MD->findDirectiveAtLoc(Loc, SM).getMacroInfo(); -} - -void MacroParamMap::expandFromPrevMacro(const MacroParamMap &Super) { - - for (value_type &Pair : *this) { - ArgTokensTy &CurrArgTokens = Pair.second; - - // For each token in the expanded macro argument. - auto It = CurrArgTokens.begin(); - while (It != CurrArgTokens.end()) { - if (It->isNot(tok::identifier)) { - ++It; - continue; - } - - const auto *II = It->getIdentifierInfo(); - assert(II); - - // Is this an argument that "Super" expands further? - if (!Super.count(II)) { - ++It; - continue; - } - - const ArgTokensTy &SuperArgTokens = Super.at(II); - - It = CurrArgTokens.insert(It, SuperArgTokens.begin(), - SuperArgTokens.end()); - std::advance(It, SuperArgTokens.size()); - It = CurrArgTokens.erase(It); - } - } -} - -void MacroParamMap::dumpToStream(llvm::raw_ostream &Out, - const Preprocessor &PP) const { - for (const std::pair Pair : *this) { - Out << Pair.first->getName() << " -> "; - dumpArgTokensToStream(Out, PP, Pair.second); - Out << '\n'; - } -} - -static void dumpArgTokensToStream(llvm::raw_ostream &Out, - const Preprocessor &PP, - const ArgTokensTy &Toks) { - TokenPrinter Printer(Out, PP); - for (Token Tok : Toks) - Printer.printToken(Tok); -} - -void TokenPrinter::printToken(const Token &Tok) { - // TODO: Handle GNU extensions where hash and hashhash occurs right before - // __VA_ARGS__. - // cppreference.com: "some compilers offer an extension that allows ## to - // appear after a comma and before __VA_ARGS__, in which case the ## does - // nothing when the variable arguments are present, but removes the comma when - // the variable arguments are not present: this makes it possible to define - // macros such as fprintf (stderr, format, ##__VA_ARGS__)" - // FIXME: Handle named variadic macro parameters (also a GNU extension). - - // If this is the first token to be printed, don't print space. - if (PrevTok.isNot(tok::unknown)) { - // If the tokens were already space separated, or if they must be to avoid - // them being implicitly pasted, add a space between them. - if(Tok.hasLeadingSpace() || ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok, - Tok)) { - // AvoidConcat doesn't check for ##, don't print a space around it. - if (PrevTok.isNot(tok::hashhash) && Tok.isNot(tok::hashhash)) { - OS << ' '; - } - } - } - - if (!Tok.isOneOf(tok::hash, tok::hashhash)) { - if (PrevTok.is(tok::hash)) - OS << '\"' << PP.getSpelling(Tok) << '\"'; - else - OS << PP.getSpelling(Tok); - } - - PrevPrevTok = PrevTok; - PrevTok = Tok; + return MacroExpansions.getExpandedMacroForLocation(MacroExpansionLoc); } diff --git a/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist b/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist --- a/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ b/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -145,7 +145,7 @@ file0 nameSET_PTR_VAR_TO_NULL - expansionptr = 0 + expansionptr =0 descriptionDereference of null pointer (loaded from variable 'ptr') @@ -588,8 +588,8 @@ col3 file0 - nameTO_NULL - expansionsetToNull(&ptr) + nameTO_NULL(&ptr) + expansionsetToNull (&ptr ) descriptionDereference of null pointer (loaded from variable 'ptr') @@ -831,8 +831,8 @@ col3 file0 - nameTO_NULL - expansionsetToNull(&a) + nameTO_NULL(&a) + expansionsetToNull (&a ) location @@ -841,8 +841,8 @@ col3 file0 - nameDEREF - expansion{ int b; b = 5; } print(a); *a + nameDEREF(a) + expansion{int b ;b =5;}print (a );*a descriptionDereference of null pointer (loaded from variable 'a') @@ -1012,8 +1012,8 @@ col3 file0 - nameWILL_UNDEF_SET_NULL_TO_PTR - expansionptr = nullptr; + nameWILL_UNDEF_SET_NULL_TO_PTR(ptr) + expansionptr =nullptr ; descriptionDereference of null pointer (loaded from variable 'ptr') @@ -1181,8 +1181,8 @@ col3 file0 - nameWILL_REDIFINE_MULTIPLE_TIMES_SET_TO_NULL - expansionptr = nullptr; + nameWILL_REDIFINE_MULTIPLE_TIMES_SET_TO_NULL(ptr) + expansionptr =nullptr ; descriptionDereference of null pointer (loaded from variable 'ptr') @@ -1350,8 +1350,8 @@ col3 file0 - namePASS_PTR_TO_MACRO_THAT_WILL_BE_UNDEFD - expansionptr = nullptr; + namePASS_PTR_TO_MACRO_THAT_WILL_BE_UNDEFD(ptr) + expansionptr =nullptr ; descriptionDereference of null pointer (loaded from variable 'ptr') @@ -1519,8 +1519,8 @@ col3 file0 - nameTO_NULL_AND_PRINT - expansiona = 0; print( "Will this , cause a crash?") + nameTO_NULL_AND_PRINT(a, "Will this , cause a crash?") + expansiona =0;print ("Will this , cause a crash?") descriptionDereference of null pointer (loaded from variable 'a') @@ -1688,8 +1688,8 @@ col3 file0 - nameTO_NULL_AND_PRINT - expansiona = 0; print( "Will this ( cause a crash?") + nameTO_NULL_AND_PRINT(a, "Will this ( cause a crash?") + expansiona =0;print ("Will this ( cause a crash?") descriptionDereference of null pointer (loaded from variable 'a') @@ -1857,8 +1857,8 @@ col3 file0 - nameTO_NULL_AND_PRINT - expansiona = 0; print( "Will this ) cause a crash?") + nameTO_NULL_AND_PRINT(a, "Will this ) cause a crash?") + expansiona =0;print ("Will this ) cause a crash?") descriptionDereference of null pointer (loaded from variable 'a') @@ -2132,8 +2132,8 @@ col3 file0 - nameCALL_FUNCTION - expansionsetToNull(&a) + nameCALL_FUNCTION(setToNull(&a)) + expansionsetToNull (&a ) descriptionDereference of null pointer (loaded from variable 'a') @@ -2549,8 +2549,8 @@ col3 file0 - nameCALL_FUNCTION - expansionsetToNullAndPrint(&a, "Hello!") + nameCALL_FUNCTION(setToNullAndPrint(&a, "Hello!")) + expansionsetToNullAndPrint (&a ,"Hello!") descriptionDereference of null pointer (loaded from variable 'a') @@ -2969,8 +2969,8 @@ col3 file0 - nameCALL_FUNCTION_WITH_TWO_PARAMS - expansionsetToNullAndPrint( &a, "Hello!") + nameCALL_FUNCTION_WITH_TWO_PARAMS(setToNullAndPrint, &a, "Hello!") + expansionsetToNullAndPrint (&a ,"Hello!") descriptionDereference of null pointer (loaded from variable 'a') @@ -3321,8 +3321,8 @@ col3 file0 - nameCALL_LAMBDA - expansion([&ptr, str] () mutable { setToNull(&ptr); })() + nameCALL_LAMBDA(([&ptr, str] () mutable { TO_NULL(&ptr); })) + expansion([&ptr ,str ]()mutable {setToNull (&ptr );})() location @@ -3331,8 +3331,8 @@ col3 file0 - nameCALL_LAMBDA - expansion([&ptr, str] () mutable { setToNull(&ptr); })() + nameCALL_LAMBDA(([&ptr, str] () mutable { TO_NULL(&ptr); })) + expansion([&ptr ,str ]()mutable {setToNull (&ptr );})() descriptionDereference of null pointer (loaded from variable 'ptr') @@ -3435,8 +3435,16 @@ col3 file0 - namePASTE_CODE - expansion{ int *ptr = nullptr; *ptr = 5; } + namePASTE_CODE({ // expected-warning{{Dereference of null pointer}} + // NOTE: If we were to add a new variable here after a comma, we'd get a + // compilation error, so this test is mainly here to show that this was also + // investigated. + // + // int *ptr = nullptr, a; + int *ptr = nullptr; + *ptr = 5; + }) + expansion{int *ptr =nullptr ;*ptr =5;} descriptionDereference of null pointer (loaded from variable 'ptr') @@ -3474,12 +3482,12 @@ start - line266 + line274 col3 file0 - line266 + line274 col5 file0 @@ -3487,12 +3495,12 @@ end - line268 + line276 col3 file0 - line268 + line276 col25 file0 @@ -3504,7 +3512,7 @@ kindevent location - line268 + line276 col3 file0 @@ -3512,12 +3520,12 @@ - line268 + line276 col3 file0 - line268 + line276 col31 file0 @@ -3537,12 +3545,12 @@ start - line269 + line277 col3 file0 - line269 + line277 col3 file0 @@ -3550,12 +3558,12 @@ end - line269 + line277 col8 file0 - line269 + line277 col8 file0 @@ -3567,7 +3575,7 @@ kindevent location - line269 + line277 col8 file0 @@ -3575,12 +3583,12 @@ - line269 + line277 col4 file0 - line269 + line277 col6 file0 @@ -3598,12 +3606,12 @@ location - line268 + line276 col3 file0 - namePOTENTIALLY_EMPTY_PARAM - expansion;ptr = nullptr + namePOTENTIALLY_EMPTY_PARAM(,ptr) + expansion;ptr =nullptr descriptionDereference of null pointer (loaded from variable 'ptr') @@ -3617,7 +3625,7 @@ issue_hash_function_offset4 location - line269 + line277 col8 file0 @@ -3625,10 +3633,10 @@ 0 - 265 - 266 - 268 - 269 + 273 + 274 + 276 + 277 @@ -3643,12 +3651,12 @@ start - line280 + line288 col3 file0 - line280 + line288 col5 file0 @@ -3656,12 +3664,12 @@ end - line282 + line290 col3 file0 - line282 + line290 col20 file0 @@ -3673,7 +3681,7 @@ kindevent location - line282 + line290 col3 file0 @@ -3681,12 +3689,12 @@ - line282 + line290 col3 file0 - line282 + line290 col27 file0 @@ -3706,12 +3714,12 @@ start - line283 + line291 col3 file0 - line283 + line291 col3 file0 @@ -3719,12 +3727,12 @@ end - line283 + line291 col8 file0 - line283 + line291 col8 file0 @@ -3736,7 +3744,7 @@ kindevent location - line283 + line291 col8 file0 @@ -3744,12 +3752,12 @@ - line283 + line291 col4 file0 - line283 + line291 col6 file0 @@ -3767,12 +3775,12 @@ location - line282 + line290 col3 file0 - nameNESTED_EMPTY_PARAM - expansion; ptr = nullptr; + nameNESTED_EMPTY_PARAM(, ptr) + expansion;ptr =nullptr ; descriptionDereference of null pointer (loaded from variable 'ptr') @@ -3786,7 +3794,7 @@ issue_hash_function_offset4 location - line283 + line291 col8 file0 @@ -3794,10 +3802,10 @@ 0 - 279 - 280 - 282 - 283 + 287 + 288 + 290 + 291 @@ -3812,12 +3820,12 @@ start - line293 + line301 col3 file0 - line293 + line301 col5 file0 @@ -3825,12 +3833,12 @@ end - line294 + line302 col3 file0 - line294 + line302 col44 file0 @@ -3842,7 +3850,7 @@ kindevent location - line294 + line302 col3 file0 @@ -3850,12 +3858,12 @@ - line294 + line302 col3 file0 - line294 + line302 col61 file0 @@ -3948,7 +3956,7 @@ kindevent location - line294 + line302 col3 file0 @@ -3956,12 +3964,12 @@ - line294 + line302 col3 file0 - line294 + line302 col61 file0 @@ -3981,12 +3989,12 @@ start - line295 + line303 col3 file0 - line295 + line303 col3 file0 @@ -3994,12 +4002,12 @@ end - line295 + line303 col8 file0 - line295 + line303 col8 file0 @@ -4011,7 +4019,7 @@ kindevent location - line295 + line303 col8 file0 @@ -4019,12 +4027,12 @@ - line295 + line303 col4 file0 - line295 + line303 col6 file0 @@ -4042,12 +4050,12 @@ location - line294 + line302 col3 file0 - nameCALL_FUNCTION_WITH_ONE_PARAM_THROUGH_MACRO - expansionsetToNull( &ptr) + nameCALL_FUNCTION_WITH_ONE_PARAM_THROUGH_MACRO(setToNull, &ptr) + expansionsetToNull (&ptr ) descriptionDereference of null pointer (loaded from variable 'ptr') @@ -4061,7 +4069,7 @@ issue_hash_function_offset3 location - line295 + line303 col8 file0 @@ -4071,10 +4079,10 @@ 48 49 - 292 - 293 - 294 - 295 + 300 + 301 + 302 + 303 @@ -4089,12 +4097,12 @@ start - line313 + line321 col3 file0 - line313 + line321 col5 file0 @@ -4102,12 +4110,12 @@ end - line314 + line322 col3 file0 - line314 + line322 col22 file0 @@ -4119,7 +4127,7 @@ kindevent location - line314 + line322 col3 file0 @@ -4127,12 +4135,12 @@ - line314 + line322 col3 file0 - line314 + line322 col42 file0 @@ -4152,12 +4160,12 @@ start - line315 + line323 col3 file0 - line315 + line323 col3 file0 @@ -4165,12 +4173,12 @@ end - line315 + line323 col8 file0 - line315 + line323 col8 file0 @@ -4182,7 +4190,7 @@ kindevent location - line315 + line323 col8 file0 @@ -4190,12 +4198,12 @@ - line315 + line323 col4 file0 - line315 + line323 col6 file0 @@ -4213,12 +4221,12 @@ location - line314 + line322 col3 file0 - nameVARIADIC_SET_TO_NULL - expansionptr = nullptr; variadicFunc( 1, 5, "haha!") + nameVARIADIC_SET_TO_NULL(ptr, 1, 5, "haha!") + expansionptr =nullptr ;variadicFunc (1,5,"haha!") descriptionDereference of null pointer (loaded from variable 'ptr') @@ -4232,7 +4240,7 @@ issue_hash_function_offset3 location - line315 + line323 col8 file0 @@ -4240,10 +4248,10 @@ 0 - 312 - 313 - 314 - 315 + 320 + 321 + 322 + 323 @@ -4258,12 +4266,12 @@ start - line322 + line330 col3 file0 - line322 + line330 col5 file0 @@ -4271,12 +4279,12 @@ end - line325 + line333 col3 file0 - line325 + line333 col22 file0 @@ -4288,7 +4296,7 @@ kindevent location - line325 + line333 col3 file0 @@ -4296,12 +4304,12 @@ - line325 + line333 col3 file0 - line325 + line333 col27 file0 @@ -4321,12 +4329,12 @@ start - line326 + line334 col3 file0 - line326 + line334 col3 file0 @@ -4334,12 +4342,12 @@ end - line326 + line334 col8 file0 - line326 + line334 col8 file0 @@ -4351,7 +4359,7 @@ kindevent location - line326 + line334 col8 file0 @@ -4359,12 +4367,12 @@ - line326 + line334 col4 file0 - line326 + line334 col6 file0 @@ -4382,12 +4390,12 @@ location - line325 + line333 col3 file0 - nameVARIADIC_SET_TO_NULL - expansionptr = nullptr; variadicFunc() + nameVARIADIC_SET_TO_NULL(ptr) + expansionptr =nullptr ;variadicFunc () descriptionDereference of null pointer (loaded from variable 'ptr') @@ -4401,7 +4409,7 @@ issue_hash_function_offset5 location - line326 + line334 col8 file0 @@ -4409,10 +4417,10 @@ 0 - 321 - 322 - 325 - 326 + 329 + 330 + 333 + 334 @@ -4427,12 +4435,12 @@ start - line341 + line349 col3 file0 - line341 + line349 col5 file0 @@ -4440,12 +4448,12 @@ end - line342 + line350 col3 file0 - line342 + line350 col30 file0 @@ -4457,7 +4465,7 @@ kindevent location - line342 + line350 col3 file0 @@ -4465,12 +4473,12 @@ - line342 + line350 col3 file0 - line342 + line350 col45 file0 @@ -4490,12 +4498,12 @@ start - line343 + line351 col3 file0 - line343 + line351 col3 file0 @@ -4503,12 +4511,12 @@ end - line343 + line351 col8 file0 - line343 + line351 col8 file0 @@ -4520,7 +4528,7 @@ kindevent location - line343 + line351 col8 file0 @@ -4528,12 +4536,12 @@ - line343 + line351 col4 file0 - line343 + line351 col6 file0 @@ -4551,12 +4559,12 @@ location - line342 + line350 col3 file0 - nameDECLARE_FUNC_AND_SET_TO_NULL - expansionvoid generated_whatever(); ptr = nullptr; + nameDECLARE_FUNC_AND_SET_TO_NULL(whatever, ptr) + expansionvoid generated_whatever ();ptr =nullptr ; descriptionDereference of null pointer (loaded from variable 'ptr') @@ -4570,7 +4578,7 @@ issue_hash_function_offset3 location - line343 + line351 col8 file0 @@ -4578,10 +4586,10 @@ 0 - 340 - 341 - 342 - 343 + 348 + 349 + 350 + 351 @@ -4596,12 +4604,12 @@ start - line350 + line358 col3 file0 - line350 + line358 col5 file0 @@ -4609,12 +4617,12 @@ end - line351 + line359 col3 file0 - line351 + line359 col19 file0 @@ -4626,7 +4634,7 @@ kindevent location - line351 + line359 col3 file0 @@ -4634,12 +4642,12 @@ - line351 + line359 col3 file0 - line351 + line359 col53 file0 @@ -4659,12 +4667,12 @@ start - line352 + line360 col3 file0 - line352 + line360 col3 file0 @@ -4672,12 +4680,12 @@ end - line352 + line360 col6 file0 - line352 + line360 col6 file0 @@ -4689,7 +4697,7 @@ kindevent location - line352 + line360 col6 file0 @@ -4697,12 +4705,12 @@ - line352 + line360 col4 file0 - line352 + line360 col4 file0 @@ -4720,12 +4728,12 @@ location - line351 + line359 col3 file0 - nameTO_NULL_AND_PRINT - expansiona = 0; print( "Will this ## cause a crash?") + nameTO_NULL_AND_PRINT(a, "Will this ## cause a crash?") + expansiona =0;print ("Will this ## cause a crash?") descriptionDereference of null pointer (loaded from variable 'a') @@ -4739,7 +4747,7 @@ issue_hash_function_offset3 location - line352 + line360 col6 file0 @@ -4747,10 +4755,10 @@ 0 - 349 - 350 - 351 - 352 + 357 + 358 + 359 + 360 @@ -4765,12 +4773,12 @@ start - line363 + line371 col3 file0 - line363 + line371 col5 file0 @@ -4778,12 +4786,12 @@ end - line364 + line372 col3 file0 - line364 + line372 col11 file0 @@ -4795,7 +4803,7 @@ kindevent location - line364 + line372 col3 file0 @@ -4803,12 +4811,12 @@ - line364 + line372 col3 file0 - line364 + line372 col23 file0 @@ -4828,12 +4836,12 @@ start - line365 + line373 col3 file0 - line365 + line373 col3 file0 @@ -4841,12 +4849,12 @@ end - line365 + line373 col8 file0 - line365 + line373 col8 file0 @@ -4858,7 +4866,7 @@ kindevent location - line365 + line373 col8 file0 @@ -4866,12 +4874,12 @@ - line365 + line373 col4 file0 - line365 + line373 col6 file0 @@ -4889,12 +4897,12 @@ location - line364 + line372 col3 file0 - namePRINT_STR - expansionprint("Hello"); ptr = nullptr + namePRINT_STR(Hello, ptr) + expansionprint ("Hello");ptr =nullptr descriptionDereference of null pointer (loaded from variable 'ptr') @@ -4908,7 +4916,7 @@ issue_hash_function_offset3 location - line365 + line373 col8 file0 @@ -4916,10 +4924,10 @@ 0 - 362 - 363 - 364 - 365 + 370 + 371 + 372 + 373 @@ -4934,12 +4942,12 @@ start - line372 + line380 col3 file0 - line372 + line380 col5 file0 @@ -4947,12 +4955,12 @@ end - line373 + line381 col3 file0 - line373 + line381 col19 file0 @@ -4964,7 +4972,7 @@ kindevent location - line373 + line381 col3 file0 @@ -4972,12 +4980,12 @@ - line373 + line381 col3 file0 - line373 + line381 col52 file0 @@ -4997,12 +5005,12 @@ start - line374 + line382 col3 file0 - line374 + line382 col3 file0 @@ -5010,12 +5018,12 @@ end - line374 + line382 col6 file0 - line374 + line382 col6 file0 @@ -5027,7 +5035,7 @@ kindevent location - line374 + line382 col6 file0 @@ -5035,12 +5043,12 @@ - line374 + line382 col4 file0 - line374 + line382 col4 file0 @@ -5058,12 +5066,12 @@ location - line373 + line381 col3 file0 - nameTO_NULL_AND_PRINT - expansiona = 0; print( "Will this # cause a crash?") + nameTO_NULL_AND_PRINT(a, "Will this # cause a crash?") + expansiona =0;print ("Will this # cause a crash?") descriptionDereference of null pointer (loaded from variable 'a') @@ -5077,7 +5085,7 @@ issue_hash_function_offset3 location - line374 + line382 col6 file0 @@ -5085,10 +5093,10 @@ 0 - 371 - 372 - 373 - 374 + 379 + 380 + 381 + 382 @@ -5103,12 +5111,12 @@ start - line420 + line428 col3 file0 - line420 + line428 col5 file0 @@ -5116,12 +5124,12 @@ end - line420 + line428 col18 file0 - line420 + line428 col43 file0 @@ -5133,7 +5141,7 @@ kindevent location - line420 + line428 col18 file0 @@ -5141,12 +5149,12 @@ - line420 + line428 col18 file0 - line420 + line428 col49 file0 @@ -5162,7 +5170,7 @@ kindevent location - line415 + line423 col1 file0 @@ -5180,12 +5188,12 @@ start - line415 + line423 col1 file0 - line415 + line423 col3 file0 @@ -5193,12 +5201,12 @@ end - line416 + line424 col3 file0 - line416 + line424 col21 file0 @@ -5210,7 +5218,7 @@ kindpop-up location - line416 + line424 col3 file0 @@ -5218,12 +5226,12 @@ - line416 + line424 col3 file0 - line416 + line424 col27 file0 @@ -5238,7 +5246,7 @@ kindpop-up location - line416 + line424 col3 file0 @@ -5246,12 +5254,12 @@ - line416 + line424 col3 file0 - line416 + line424 col27 file0 @@ -5266,7 +5274,7 @@ kindevent location - line416 + line424 col3 file0 @@ -5274,12 +5282,12 @@ - line416 + line424 col3 file0 - line416 + line424 col27 file0 @@ -5297,12 +5305,12 @@ location - line416 + line424 col3 file0 - nameEUCLIDEAN_ALGORITHM - expansionif (A<0 ){A=-A;} if ( B<0 ){ B=- B;}return B / ( B - B); + nameEUCLIDEAN_ALGORITHM(A, B) + expansionif (A <0){A =-A ;}if (B <0){B =-B ;}return B /(B -B ); descriptionDivision by zero @@ -5316,7 +5324,7 @@ issue_hash_function_offset1 location - line416 + line424 col3 file0 @@ -5324,10 +5332,10 @@ 0 - 415 - 416 - 419 - 420 + 423 + 424 + 427 + 428 @@ -5342,12 +5350,12 @@ start - line435 + line443 col3 file0 - line435 + line443 col5 file0 @@ -5355,12 +5363,12 @@ end - line436 + line444 col3 file0 - line436 + line444 col25 file0 @@ -5372,7 +5380,7 @@ kindevent location - line436 + line444 col3 file0 @@ -5380,12 +5388,12 @@ - line436 + line444 col3 file0 - line436 + line444 col67 file0 @@ -5405,12 +5413,12 @@ start - line437 + line445 col3 file0 - line437 + line445 col3 file0 @@ -5418,12 +5426,12 @@ end - line437 + line445 col8 file0 - line437 + line445 col8 file0 @@ -5435,7 +5443,7 @@ kindevent location - line437 + line445 col8 file0 @@ -5443,12 +5451,12 @@ - line437 + line445 col4 file0 - line437 + line445 col6 file0 @@ -5466,12 +5474,12 @@ location - line436 + line444 col3 file0 - nameYET_ANOTHER_SET_TO_NULL - expansionprint((void *)5); print((void *)"Remember the Vasa"); ptr = nullptr; + nameYET_ANOTHER_SET_TO_NULL(5, DO_NOTHING2("Remember the Vasa"), ptr) + expansionprint ((void *)5);print ((void *)"Remember the Vasa");ptr =nullptr ; descriptionDereference of null pointer (loaded from variable 'ptr') @@ -5485,7 +5493,7 @@ issue_hash_function_offset3 location - line437 + line445 col8 file0 @@ -5493,10 +5501,10 @@ 0 - 434 - 435 - 436 - 437 + 442 + 443 + 444 + 445 @@ -5511,12 +5519,12 @@ start - line448 + line456 col3 file0 - line448 + line456 col4 file0 @@ -5524,12 +5532,12 @@ end - line448 + line456 col7 file0 - line448 + line456 col11 file0 @@ -5541,7 +5549,7 @@ kindevent location - line448 + line456 col7 file0 @@ -5549,12 +5557,12 @@ - line448 + line456 col7 file0 - line448 + line456 col16 file0 @@ -5570,7 +5578,7 @@ kindevent location - line449 + line457 col7 file0 @@ -5578,12 +5586,12 @@ - line449 + line457 col5 file0 - line449 + line457 col13 file0 @@ -5601,12 +5609,12 @@ location - line448 + line456 col7 file0 namevalue - expansiongarbage_ + expansiongarbage_value descriptionDivision by zero @@ -5620,7 +5628,7 @@ issue_hash_function_offset2 location - line449 + line457 col7 file0 @@ -5628,9 +5636,9 @@ 0 - 447 - 448 - 449 + 455 + 456 + 457 @@ -5645,12 +5653,12 @@ start - line460 + line468 col33 file0 - line460 + line468 col33 file0 @@ -5658,12 +5666,12 @@ end - line460 + line468 col37 file0 - line460 + line468 col39 file0 @@ -5675,7 +5683,7 @@ kindevent location - line460 + line468 col37 file0 @@ -5683,12 +5691,12 @@ - line460 + line468 col37 file0 - line460 + line468 col41 file0 @@ -5704,7 +5712,7 @@ kindevent location - line459 + line467 col1 file0 @@ -5718,7 +5726,7 @@ kindevent location - line459 + line467 col1 file0 @@ -5726,12 +5734,12 @@ - line459 + line467 col1 file0 - line459 + line467 col16 file0 @@ -5747,7 +5755,7 @@ kindevent location - line460 + line468 col37 file0 @@ -5755,12 +5763,12 @@ - line460 + line468 col37 file0 - line460 + line468 col41 file0 @@ -5780,12 +5788,12 @@ start - line460 + line468 col37 file0 - line460 + line468 col39 file0 @@ -5793,12 +5801,12 @@ end - line460 + line468 col35 file0 - line460 + line468 col35 file0 @@ -5810,7 +5818,7 @@ kindevent location - line460 + line468 col35 file0 @@ -5818,12 +5826,12 @@ - line460 + line468 col33 file0 - line460 + line468 col41 file0 @@ -5841,12 +5849,12 @@ location - line459 + line467 col1 file0 - nameAPPLY_ZERO1 - expansionint foo() { return x; }(0) + nameAPPLY_ZERO1(FOO) + expansionint foo (){return 0;} descriptionDivision by zero @@ -5860,7 +5868,7 @@ issue_hash_function_offset0 location - line460 + line468 col35 file0 @@ -5868,8 +5876,8 @@ 0 - 459 - 460 + 467 + 468 @@ -5884,12 +5892,12 @@ start - line469 + line477 col33 file0 - line469 + line477 col33 file0 @@ -5897,12 +5905,12 @@ end - line469 + line477 col37 file0 - line469 + line477 col39 file0 @@ -5914,7 +5922,7 @@ kindevent location - line469 + line477 col37 file0 @@ -5922,12 +5930,12 @@ - line469 + line477 col37 file0 - line469 + line477 col41 file0 @@ -5943,7 +5951,7 @@ kindevent location - line468 + line476 col1 file0 @@ -5957,7 +5965,7 @@ kindevent location - line468 + line476 col1 file0 @@ -5965,12 +5973,12 @@ - line468 + line476 col1 file0 - line468 + line476 col11 file0 @@ -5986,7 +5994,7 @@ kindevent location - line469 + line477 col37 file0 @@ -5994,12 +6002,12 @@ - line469 + line477 col37 file0 - line469 + line477 col41 file0 @@ -6019,12 +6027,12 @@ start - line469 + line477 col37 file0 - line469 + line477 col39 file0 @@ -6032,12 +6040,12 @@ end - line469 + line477 col35 file0 - line469 + line477 col35 file0 @@ -6049,7 +6057,7 @@ kindevent location - line469 + line477 col35 file0 @@ -6057,12 +6065,12 @@ - line469 + line477 col33 file0 - line469 + line477 col41 file0 @@ -6080,12 +6088,12 @@ location - line468 + line476 col1 file0 nameAPPLY_ZERO2 - expansionint bar() { return 0; } + expansionint bar (){return 0;} descriptionDivision by zero @@ -6099,7 +6107,7 @@ issue_hash_function_offset0 location - line469 + line477 col35 file0 @@ -6107,8 +6115,8 @@ 0 - 468 - 469 + 476 + 477 @@ -6123,12 +6131,12 @@ start - line481 + line489 col3 file0 - line481 + line489 col5 file0 @@ -6136,12 +6144,12 @@ end - line482 + line490 col3 file0 - line482 + line490 col10 file0 @@ -6153,7 +6161,7 @@ kindevent location - line482 + line490 col3 file0 @@ -6161,12 +6169,12 @@ - line482 + line490 col3 file0 - line482 + line490 col28 file0 @@ -6182,7 +6190,7 @@ kindevent location - line483 + line491 col13 file0 @@ -6190,12 +6198,12 @@ - line483 + line491 col10 file0 - line483 + line491 col15 file0 @@ -6213,12 +6221,12 @@ location - line482 + line490 col3 file0 - nameDISPATCH - expansionfoo(x, "LF1M healer");x = 0;; + nameDISPATCH(x, "LF1M healer") + expansionfoo (x ,"LF1M healer");x =0;; descriptionDivision by zero @@ -6232,7 +6240,7 @@ issue_hash_function_offset3 location - line483 + line491 col13 file0 @@ -6240,10 +6248,10 @@ 0 - 480 - 481 - 482 - 483 + 488 + 489 + 490 + 491 @@ -6258,12 +6266,12 @@ start - line494 + line502 col3 file0 - line494 + line502 col5 file0 @@ -6271,12 +6279,12 @@ end - line495 + line503 col3 file0 - line495 + line503 col16 file0 @@ -6288,7 +6296,7 @@ kindevent location - line495 + line503 col3 file0 @@ -6296,12 +6304,12 @@ - line495 + line503 col3 file0 - line495 + line503 col71 file0 @@ -6317,7 +6325,7 @@ kindevent location - line496 + line504 col13 file0 @@ -6325,12 +6333,12 @@ - line496 + line504 col10 file0 - line496 + line504 col15 file0 @@ -6348,12 +6356,12 @@ location - line495 + line503 col3 file0 - nameCONCAT_VA_ARGS - expansionvariadicCFunction(x, "You need to construct additional pylons.",'c', 9);x = 0; + nameCONCAT_VA_ARGS(x, "You need to construct additional pylons.", 'c', 9) + expansionvariadicCFunction (x ,"You need to construct additional pylons.",'c',9);x =0; descriptionDivision by zero @@ -6367,7 +6375,7 @@ issue_hash_function_offset3 location - line496 + line504 col13 file0 @@ -6375,10 +6383,10 @@ 0 - 493 - 494 - 495 - 496 + 501 + 502 + 503 + 504 @@ -6393,12 +6401,12 @@ start - line502 + line510 col3 file0 - line502 + line510 col5 file0 @@ -6406,12 +6414,12 @@ end - line503 + line511 col3 file0 - line503 + line511 col16 file0 @@ -6423,7 +6431,7 @@ kindevent location - line503 + line511 col3 file0 @@ -6431,12 +6439,12 @@ - line503 + line511 col3 file0 - line503 + line511 col44 file0 @@ -6452,7 +6460,7 @@ kindevent location - line504 + line512 col13 file0 @@ -6460,12 +6468,12 @@ - line504 + line512 col10 file0 - line504 + line512 col15 file0 @@ -6483,12 +6491,12 @@ location - line503 + line511 col3 file0 - nameCONCAT_VA_ARGS - expansionvariadicCFunction(x, "You need to construct",);x = 0; + nameCONCAT_VA_ARGS(x, "You need to construct") + expansionvariadicCFunction (x ,"You need to construct");x =0; descriptionDivision by zero @@ -6502,7 +6510,7 @@ issue_hash_function_offset3 location - line504 + line512 col13 file0 @@ -6510,10 +6518,10 @@ 0 - 501 - 502 - 503 - 504 + 509 + 510 + 511 + 512 @@ -6528,12 +6536,12 @@ start - line514 + line522 col3 file0 - line514 + line522 col5 file0 @@ -6541,12 +6549,12 @@ end - line515 + line523 col3 file0 - line515 + line523 col21 file0 @@ -6558,7 +6566,7 @@ kindevent location - line515 + line523 col3 file0 @@ -6566,12 +6574,12 @@ - line515 + line523 col3 file0 - line515 + line523 col71 file0 @@ -6587,7 +6595,7 @@ kindevent location - line516 + line524 col13 file0 @@ -6595,12 +6603,12 @@ - line516 + line524 col10 file0 - line516 + line524 col15 file0 @@ -6618,12 +6626,12 @@ location - line515 + line523 col3 file0 - nameSTRINGIFIED_VA_ARGS - expansionvariadicCFunction(x, "Additional supply depots required.", "'a'", 10);x = 0; + nameSTRINGIFIED_VA_ARGS(x, "Additional supply depots required.", 'a', 10) + expansionvariadicCFunction (x ,"Additional supply depots required.","'a', 10");x =0; descriptionDivision by zero @@ -6637,7 +6645,7 @@ issue_hash_function_offset3 location - line516 + line524 col13 file0 @@ -6645,10 +6653,10 @@ 0 - 513 - 514 - 515 - 516 + 521 + 522 + 523 + 524 @@ -6663,12 +6671,12 @@ start - line524 + line532 col3 file0 - line524 + line532 col5 file0 @@ -6676,12 +6684,12 @@ end - line525 + line533 col3 file0 - line525 + line533 col21 file0 @@ -6693,7 +6701,7 @@ kindevent location - line525 + line533 col3 file0 @@ -6701,12 +6709,12 @@ - line525 + line533 col3 file0 - line525 + line533 col62 file0 @@ -6722,7 +6730,7 @@ kindevent location - line526 + line534 col13 file0 @@ -6730,12 +6738,12 @@ - line526 + line534 col10 file0 - line526 + line534 col15 file0 @@ -6753,12 +6761,12 @@ location - line525 + line533 col3 file0 - nameSTRINGIFIED_VA_ARGS - expansionvariadicCFunction(x, "Additional supply depots required.", ")";x = 0; + nameSTRINGIFIED_VA_ARGS(x, "Additional supply depots required.") + expansionvariadicCFunction (x ,"Additional supply depots required.","");x =0; descriptionDivision by zero @@ -6772,7 +6780,7 @@ issue_hash_function_offset3 location - line526 + line534 col13 file0 @@ -6780,10 +6788,10 @@ 0 - 523 - 524 - 525 - 526 + 531 + 532 + 533 + 534 @@ -6798,12 +6806,12 @@ start - line537 + line545 col3 file0 - line537 + line545 col5 file0 @@ -6811,12 +6819,12 @@ end - line539 + line547 col3 file0 - line539 + line547 col15 file0 @@ -6828,7 +6836,7 @@ kindevent location - line539 + line547 col3 file0 @@ -6836,12 +6844,12 @@ - line539 + line547 col3 file0 - line539 + line547 col26 file0 @@ -6857,7 +6865,7 @@ kindevent location - line540 + line548 col13 file0 @@ -6865,12 +6873,12 @@ - line540 + line548 col10 file0 - line540 + line548 col15 file0 @@ -6888,12 +6896,12 @@ location - line539 + line547 col3 file0 - nameBZ44493_GNUVA - expansion--(a); + nameBZ44493_GNUVA(a, "arg2") + expansion--(a ); descriptionDivision by zero @@ -6907,7 +6915,7 @@ issue_hash_function_offset4 location - line540 + line548 col13 file0 @@ -6915,11 +6923,11 @@ 0 - 536 - 537 - 538 - 539 - 540 + 544 + 545 + 546 + 547 + 548 diff --git a/clang/test/Analysis/plist-macros-with-expansion-ctu.c b/clang/test/Analysis/plist-macros-with-expansion-ctu.c --- a/clang/test/Analysis/plist-macros-with-expansion-ctu.c +++ b/clang/test/Analysis/plist-macros-with-expansion-ctu.c @@ -8,7 +8,7 @@ // RUN: -analyzer-config ctu-dir=%t/ctudir \ // RUN: -analyzer-config expand-macros=true \ // RUN: -analyzer-output=plist-multi-file -o %t.plist -verify %s - +// XFAIL: * // Check the macro expansions from the plist output here, to make the test more // understandable. // RUN: FileCheck --input-file=%t.plist %s diff --git a/clang/test/Analysis/plist-macros-with-expansion.cpp b/clang/test/Analysis/plist-macros-with-expansion.cpp --- a/clang/test/Analysis/plist-macros-with-expansion.cpp +++ b/clang/test/Analysis/plist-macros-with-expansion.cpp @@ -26,7 +26,7 @@ } // CHECK: nameSET_PTR_VAR_TO_NULL -// CHECK-NEXT: expansionptr = 0 +// CHECK-NEXT: expansionptr =0 #define NULL 0 #define SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO \ @@ -58,8 +58,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL -// CHECK-NEXT: expansionsetToNull(&ptr) +// CHECK: nameTO_NULL(&ptr) +// CHECK-NEXT: expansionsetToNull (&ptr ) #define DOES_NOTHING(x) \ { \ @@ -78,11 +78,11 @@ DEREF(a) = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL -// CHECK-NEXT: expansionsetToNull(&a) +// CHECK: nameTO_NULL(&a) +// CHECK-NEXT: expansionsetToNull (&a ) -// CHECK: nameDEREF -// CHECK-NEXT: expansion{ int b; b = 5; } print(a); *a +// CHECK: nameDEREF(a) +// CHECK-NEXT: expansion{int b ;b =5;}print (a );*a //===----------------------------------------------------------------------===// // Tests for undefining and/or redifining macros. @@ -99,8 +99,8 @@ #undef WILL_UNDEF_SET_NULL_TO_PTR -// CHECK: nameWILL_UNDEF_SET_NULL_TO_PTR -// CHECK-NEXT: expansionptr = nullptr; +// CHECK: nameWILL_UNDEF_SET_NULL_TO_PTR(ptr) +// CHECK-NEXT: expansionptr =nullptr ; #define WILL_REDIFINE_MULTIPLE_TIMES_SET_TO_NULL(ptr) \ /* Nothing */ @@ -119,8 +119,8 @@ print("This string shouldn't be in the plist file at all. Or anywhere, " \ "but here."); -// CHECK: nameWILL_REDIFINE_MULTIPLE_TIMES_SET_TO_NULL -// CHECK-NEXT: expansionptr = nullptr; +// CHECK: nameWILL_REDIFINE_MULTIPLE_TIMES_SET_TO_NULL(ptr) +// CHECK-NEXT: expansionptr =nullptr ; #define WILL_UNDEF_SET_NULL_TO_PTR_2(ptr) \ ptr = nullptr; @@ -134,9 +134,9 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Expand arguments. -// CHECK: namePASS_PTR_TO_MACRO_THAT_WILL_BE_UNDEFD -// CHECK-NEXT: expansionptr = nullptr; + +// CHECK: namePASS_PTR_TO_MACRO_THAT_WILL_BE_UNDEFD(ptr) +// CHECK-NEXT: expansionptr =nullptr ; #undef WILL_UNDEF_SET_NULL_TO_PTR_2 @@ -161,8 +161,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL_AND_PRINT -// CHECK-NEXT: expansiona = 0; print( "Will this , cause a crash?") +// CHECK: nameTO_NULL_AND_PRINT(a, "Will this , cause a crash?") +// CHECK-NEXT: expansiona =0;print ("Will this , cause a crash?") void macroArgContainsLParenInStringTest() { int *a; @@ -170,8 +170,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL_AND_PRINT -// CHECK-NEXT: expansiona = 0; print( "Will this ( cause a crash?") +// CHECK: nameTO_NULL_AND_PRINT(a, "Will this ( cause a crash?") +// CHECK-NEXT: expansiona =0;print ("Will this ( cause a crash?") void macroArgContainsRParenInStringTest() { int *a; @@ -179,8 +179,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL_AND_PRINT -// CHECK-NEXT: expansiona = 0; print( "Will this ) cause a crash?") +// CHECK: nameTO_NULL_AND_PRINT(a, "Will this ) cause a crash?") +// CHECK-NEXT: expansiona =0;print ("Will this ) cause a crash?") #define CALL_FUNCTION(funcCall) \ funcCall @@ -193,8 +193,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameCALL_FUNCTION -// CHECK-NEXT: expansionsetToNull(&a) +// CHECK: nameCALL_FUNCTION(setToNull(&a)) +// CHECK-NEXT: expansionsetToNull (&a ) void setToNullAndPrint(int **vptr, const char *str) { setToNull(vptr); @@ -207,8 +207,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameCALL_FUNCTION -// CHECK-NEXT: expansionsetToNullAndPrint(&a, "Hello!") +// CHECK: nameCALL_FUNCTION(setToNullAndPrint(&a, "Hello!")) +// CHECK-NEXT: expansionsetToNullAndPrint (&a ,"Hello!") #define CALL_FUNCTION_WITH_TWO_PARAMS(funcCall, param1, param2) \ funcCall(param1, param2) @@ -219,8 +219,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameCALL_FUNCTION_WITH_TWO_PARAMS -// CHECK-NEXT: expansionsetToNullAndPrint( &a, "Hello!") +// CHECK: nameCALL_FUNCTION_WITH_TWO_PARAMS(setToNullAndPrint, &a, "Hello!") +// CHECK-NEXT: expansionsetToNullAndPrint (&a ,"Hello!") #define CALL_LAMBDA(l) \ l() @@ -234,8 +234,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameCALL_LAMBDA -// CHECK-NEXT: expansion([&ptr, str] () mutable { setToNull(&ptr); })() +// CHECK: nameCALL_LAMBDA(([&ptr, str] () mutable { TO_NULL(&ptr); })) +// CHECK-NEXT: expansion([&ptr ,str ]()mutable {setToNull (&ptr );})() #define PASTE_CODE(code) \ code @@ -245,15 +245,23 @@ // NOTE: If we were to add a new variable here after a comma, we'd get a // compilation error, so this test is mainly here to show that this was also // investigated. - + // // int *ptr = nullptr, a; int *ptr = nullptr; *ptr = 5; }) } -// CHECK: namePASTE_CODE -// CHECK-NEXT: expansion{ int *ptr = nullptr; *ptr = 5; } +// CHECK: namePASTE_CODE({ // expected-warning +// CHECK-NEXT: // NOTE: If we were to add a new variable here after a comma, we'd get a +// CHECK-NEXT: // compilation error, so this test is mainly here to show that this was also +// CHECK-NEXT: // investigated. +// CHECK-NEXT: // +// CHECK-NEXT: // int *ptr = nullptr, a; +// CHECK-NEXT: int *ptr = nullptr; +// CHECK-NEXT: *ptr = 5; +// CHECK-NEXT: }) +// CHECK-NEXT: expansion{int *ptr =nullptr ;*ptr =5;} // Example taken from // https://gcc.gnu.org/onlinedocs/cpp/Macro-Arguments.html#Macro-Arguments. @@ -269,8 +277,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: namePOTENTIALLY_EMPTY_PARAM -// CHECK-NEXT: expansion;ptr = nullptr +// CHECK: namePOTENTIALLY_EMPTY_PARAM(,ptr) +// CHECK-NEXT: expansion;ptr =nullptr #define NESTED_EMPTY_PARAM(a, b) \ POTENTIALLY_EMPTY_PARAM(a, b); @@ -283,8 +291,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameNESTED_EMPTY_PARAM -// CHECK-NEXT: expansion; ptr = nullptr; +// CHECK: nameNESTED_EMPTY_PARAM(, ptr) +// CHECK-NEXT: expansion;ptr =nullptr ; #define CALL_FUNCTION_WITH_ONE_PARAM_THROUGH_MACRO(func, param) \ CALL_FUNCTION(func(param)) @@ -295,8 +303,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameCALL_FUNCTION_WITH_ONE_PARAM_THROUGH_MACRO -// CHECK-NEXT: expansionsetToNull( &ptr) +// CHECK: nameCALL_FUNCTION_WITH_ONE_PARAM_THROUGH_MACRO(setToNull, &ptr) +// CHECK-NEXT: expansionsetToNull (&ptr ) //===----------------------------------------------------------------------===// // Tests for variadic macro arguments. @@ -315,8 +323,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameVARIADIC_SET_TO_NULL -// CHECK-NEXT: expansionptr = nullptr; variadicFunc( 1, 5, "haha!") +// CHECK: nameVARIADIC_SET_TO_NULL(ptr, 1, 5, "haha!") +// CHECK-NEXT: expansionptr =nullptr ;variadicFunc (1,5,"haha!") void variadicMacroArgumentWithoutAnyArgumentTest() { int *ptr; @@ -326,8 +334,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameVARIADIC_SET_TO_NULL -// CHECK-NEXT: expansionptr = nullptr; variadicFunc() +// CHECK: nameVARIADIC_SET_TO_NULL(ptr) +// CHECK-NEXT: expansionptr =nullptr ;variadicFunc () //===----------------------------------------------------------------------===// // Tests for # and ##. @@ -343,8 +351,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameDECLARE_FUNC_AND_SET_TO_NULL -// CHECK-NEXT: expansionvoid generated_whatever(); ptr = nullptr; +// CHECK: nameDECLARE_FUNC_AND_SET_TO_NULL(whatever, ptr) +// CHECK-NEXT: expansionvoid generated_whatever ();ptr =nullptr ; void macroArgContainsHashHashInStringTest() { int *a; @@ -352,8 +360,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL_AND_PRINT -// CHECK-NEXT: expansiona = 0; print( "Will this ## cause a crash?") +// CHECK: nameTO_NULL_AND_PRINT(a, "Will this ## cause a crash?") +// CHECK-NEXT: expansiona =0;print ("Will this ## cause a crash?") #define PRINT_STR(str, ptr) \ print(#str); \ @@ -365,8 +373,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: namePRINT_STR -// CHECK-NEXT: expansionprint("Hello"); ptr = nullptr +// CHECK: namePRINT_STR(Hello, ptr) +// CHECK-NEXT: expansionprint ("Hello");ptr =nullptr void macroArgContainsHashInStringTest() { int *a; @@ -374,8 +382,8 @@ *a = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameTO_NULL_AND_PRINT -// CHECK-NEXT: expansiona = 0; print( "Will this # cause a crash?") +// CHECK: nameTO_NULL_AND_PRINT(a, "Will this # cause a crash?") +// CHECK-NEXT: expansiona =0;print ("Will this # cause a crash?") //===----------------------------------------------------------------------===// // Tests for more complex macro expansions. @@ -420,8 +428,8 @@ int tmp = 8 / (getLowestCommonDenominator(5, 7) - 1); print(&tmp); } -// CHECK: nameEUCLIDEAN_ALGORITHM -// CHECK-NEXT: expansionif (A<0 ){A=-A;} if ( B<0 ){ B=- B;}return B / ( B - B); +// CHECK: nameEUCLIDEAN_ALGORITHM(A, B) +// CHECK-NEXT: expansionif (A <0){A =-A ;}if (B <0){B =-B ;}return B /(B -B ); #define YET_ANOTHER_SET_TO_NULL(x, y, z) \ print((void *) x); \ @@ -436,8 +444,8 @@ YET_ANOTHER_SET_TO_NULL(5, DO_NOTHING2("Remember the Vasa"), ptr); *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: nameYET_ANOTHER_SET_TO_NULL -// CHECK-NEXT: expansionprint((void *)5); print((void *)"Remember the Vasa"); ptr = nullptr; +// CHECK: nameYET_ANOTHER_SET_TO_NULL(5, DO_NOTHING2("Remember the Vasa"), ptr) +// CHECK-NEXT: expansionprint ((void *)5);print ((void *)"Remember the Vasa");ptr =nullptr ; int garbage_value; @@ -451,7 +459,7 @@ } // CHECK: namevalue -// CHECK-NEXT: expansiongarbage_ +// CHECK-NEXT: expansiongarbage_value #define FOO(x) int foo() { return x; } #define APPLY_ZERO1(function) function(0) @@ -459,8 +467,8 @@ APPLY_ZERO1(FOO) void useZeroApplier1() { (void)(1 / foo()); } // expected-warning{{Division by zero}} -// CHECK: nameAPPLY_ZERO1 -// CHECK-NEXT: expansionint foo() { return x; }(0) +// CHECK: nameAPPLY_ZERO1(FOO) +// CHECK-NEXT: expansionint foo (){return 0;} #define BAR(x) int bar() { return x; } #define APPLY_ZERO2 BAR(0) @@ -469,7 +477,7 @@ void useZeroApplier2() { (void)(1 / bar()); } // expected-warning{{Division by zero}} // CHECK: nameAPPLY_ZERO2 -// CHECK-NEXT: expansionint bar() { return 0; } +// CHECK-NEXT: expansionint bar (){return 0;} void foo(int &x, const char *str); @@ -482,8 +490,8 @@ DISPATCH(x, "LF1M healer"); (void)(10 / x); // expected-warning{{Division by zero}} } -// CHECK: nameDISPATCH -// CHECK-NEXT: expansionfoo(x, "LF1M healer");x = 0;; +// CHECK: nameDISPATCH(x, "LF1M healer") +// CHECK-NEXT: expansionfoo (x ,"LF1M healer");x =0;; void variadicCFunction(int &x, const char *str, ...); @@ -495,17 +503,17 @@ CONCAT_VA_ARGS(x, "You need to construct additional pylons.", 'c', 9); (void)(10 / x); // expected-warning{{Division by zero}} } -// CHECK: nameCONCAT_VA_ARGS -// CHECK-NEXT: expansionvariadicCFunction(x, "You need to construct additional pylons.",'c', 9);x = 0; +// CHECK: nameCONCAT_VA_ARGS(x, "You need to construct additional pylons.", 'c', 9) +// CHECK-NEXT: expansionvariadicCFunction (x ,"You need to construct additional pylons.",'c',9);x =0; void concatVA_ARGSEmpty(void) { int x = 1; CONCAT_VA_ARGS(x, "You need to construct"); (void)(10 / x); // expected-warning{{Division by zero}} } -// FIXME: The comma shouldn't be present after the last argument. -// CHECK: nameCONCAT_VA_ARGS -// CHECK-NEXT: expansionvariadicCFunction(x, "You need to construct",);x = 0; + +// CHECK: nameCONCAT_VA_ARGS(x, "You need to construct") +// CHECK-NEXT: expansionvariadicCFunction (x ,"You need to construct");x =0; #define STRINGIFIED_VA_ARGS(i, fmt, ...) variadicCFunction(i, fmt, #__VA_ARGS__); \ i = 0; @@ -516,9 +524,9 @@ (void)(10 / x); // expected-warning{{Division by zero}} } -// FIXME: Stringify and escape __VA_ARGS__ correctly. -// CHECK: nameSTRINGIFIED_VA_ARGS -// CHECK-NEXT: expansionvariadicCFunction(x, "Additional supply depots required.", "'a'", 10);x = 0; + +// CHECK: nameSTRINGIFIED_VA_ARGS(x, "Additional supply depots required.", 'a', 10) +// CHECK-NEXT: expansionvariadicCFunction (x ,"Additional supply depots required.","'a', 10");x =0; void stringifyVA_ARGSEmpty(void) { int x = 1; @@ -526,9 +534,9 @@ (void)(10 / x); // expected-warning{{Division by zero}} } -// FIXME: Stringify and escape __VA_ARGS__ correctly. -// CHECK: nameSTRINGIFIED_VA_ARGS -// CHECK-NEXT: expansionvariadicCFunction(x, "Additional supply depots required.", ")";x = 0; + +// CHECK: nameSTRINGIFIED_VA_ARGS(x, "Additional supply depots required.") +// CHECK-NEXT: expansionvariadicCFunction (x ,"Additional supply depots required.","");x =0; // bz44493: Support GNU-style named variadic arguments in plister #define BZ44493_GNUVA(i, args...) --(i); @@ -541,5 +549,5 @@ return 0; } -// CHECK: nameBZ44493_GNUVA -// CHECK-NEXT: expansion--(a); +// CHECK: nameBZ44493_GNUVA(a, "arg2") +// CHECK-NEXT: expansion--(a );