[PATCH] D57892: [analyzer] Fix macro printer crash when macro comes from another translation unit
Szelethus added a comment. Whoops, incorrect commit title and description. Anyways, the committed code and the revision number is OK... Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57892/new/ https://reviews.llvm.org/D57892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57892: [analyzer] Fix macro printer crash when macro comes from another translation unit
This revision was automatically updated to reflect the committed changes. Closed by commit rL354806: [analyzer] Fix infinite recursion in printing macros (authored by Szelethus, committed by ). Herald added subscribers: llvm-commits, Charusso. Herald added a project: LLVM. Changed prior to commit: https://reviews.llvm.org/D57892?vs=185758=188219#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57892/new/ https://reviews.llvm.org/D57892 Files: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -842,6 +842,9 @@ MacroNameAndArgs Info = getMacroNameAndArgs(SM.getExpansionLoc(MacroLoc), PP); + if (!Info.MI) +return Info.Name; + // Manually expand its arguments from the previous macro. Info.Args.expandFromPrevMacro(PrevArgs); @@ -936,7 +939,14 @@ assert(II && "Failed to acquire the IndetifierInfo for the macro!"); const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc); - assert(MI && "The macro must've been defined at it's expansion location!"); + // 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. // Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -842,6 +842,9 @@ MacroNameAndArgs Info = getMacroNameAndArgs(SM.getExpansionLoc(MacroLoc), PP); + if (!Info.MI) +return Info.Name; + // Manually expand its arguments from the previous macro. Info.Args.expandFromPrevMacro(PrevArgs); @@ -936,7 +939,14 @@ assert(II && "Failed to acquire the IndetifierInfo for the macro!"); const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc); - assert(MI && "The macro must've been defined at it's expansion location!"); + // 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. // ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57892: [analyzer] Fix macro printer crash when macro comes from another translation unit
Szelethus accepted this revision. Szelethus added a reviewer: martong. Szelethus added a comment. This revision is now accepted and ready to land. Yup, cheers! Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57892/new/ https://reviews.llvm.org/D57892 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57892: [analyzer] Fix macro printer crash when macro comes from another translation unit
bruntib created this revision. bruntib added reviewers: NoQ, george.karpenkov, Szelethus, xazax.hun. Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware. Herald added a project: clang. Repository: rC Clang https://reviews.llvm.org/D57892 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp === --- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -820,6 +820,9 @@ return Info.Name; AlreadyProcessedTokens.insert(IDInfo); + if (!Info.MI) +return Info.Name; + // Manually expand its arguments from the previous macro. Info.Args.expandFromPrevMacro(PrevArgs); @@ -917,7 +920,14 @@ assert(II && "Failed to acquire the IndetifierInfo for the macro!"); const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc); - assert(MI && "The macro must've been defined at it's expansion location!"); + // 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. // Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp === --- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -820,6 +820,9 @@ return Info.Name; AlreadyProcessedTokens.insert(IDInfo); + if (!Info.MI) +return Info.Name; + // Manually expand its arguments from the previous macro. Info.Args.expandFromPrevMacro(PrevArgs); @@ -917,7 +920,14 @@ assert(II && "Failed to acquire the IndetifierInfo for the macro!"); const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc); - assert(MI && "The macro must've been defined at it's expansion location!"); + // 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. // ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits