martong marked an inline comment as done.
martong 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;
----------------
Szelethus wrote:
> NoQ wrote:
> > 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?
> Ugh, now that you say it that is a valid concern. I had to deal with that 
> back in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352
Solving this does not seem easy in my opinion. To handle `#undef`s we should 
build an infrastructure where summaries can reference callable objects. This is 
necessary, because in `evalCall` the value of `EOF` would depend on the souce 
location of the call expression of the function with the summary. Not 
impossible to solve, but certainly introduces complexity. Do you think that the 
redefinition of EOF is so common? I mean maybe it is too much hassle for a very 
rare edge case (?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74473/new/

https://reviews.llvm.org/D74473



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to