[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 14:33:49 PDT 2019


Charusso added a comment.

In D69731#1730784 <https://reviews.llvm.org/D69731#1730784>, @NoQ wrote:

> I'm not sure though - because we somehow survived without this for like 10 years. Eg. `BugReporterVisitors.cpp`: [...]
>  I'd love to see some actual use before committing.


"Teaser":

  const Preprocessor &PP = C.getPreprocessor();
  Optional<bool> WantSafeFunctions;
    
  if (PP.isMacroDefined("__STDC_LIB_EXT1__")) {
    MacroDefinition MD = PP.getMacroDefinition("__STDC_WANT_LIB_EXT1__");
    if (const MacroInfo *MI = MD.getMacroInfo()) {
      const Token &T = MI->tokens().back();
      StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
      llvm::APInt IntValue;
      ValueStr.getAsInteger(10, IntValue);
      WantSafeFunctions = IntValue.getZExtValue();
    }
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731





More information about the cfe-commits mailing list