[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 13 09:38:17 PST 2020
NoQ added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+ const auto MacroIt = llvm::find_if(
+ PP.macros(), [&](const auto &K) { return K.first->getName() == Macro; });
+ if (MacroIt == PP.macro_end())
+ return llvm::None;
----------------
martong wrote:
> Szelethus wrote:
> > This seems a bit clunky even for the `Preprocessor` -- how about
> >
> > ```lang=c++
> > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > if (!MacroII)
> > return;
> > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > assert(MI);
> > ```
> Ok, but we cannot assert on `MI`, because there may be cases when the macro is not defined in a TU. In that case we should just return with None.
What exactly happens when the macro is `#undef`-ined and redefined? We get the last redefinition that's valid at the end of the translation unit, right? Can we check whether there are multiple definitions and guard against that?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74473/new/
https://reviews.llvm.org/D74473
More information about the cfe-commits
mailing list