[clang] [analyzer] Delay the checker constructions after parsing (PR #127409)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 17 02:54:42 PST 2025


================
@@ -40,17 +40,28 @@ enum class OpenVariant {
   OpenAt
 };
 
+static CachedMacroValue getCreateFlagValue(const ASTContext &Ctx,
+                                           const Preprocessor &PP) {
+  CachedMacroValue MacroVal("O_CREAT", PP);
+  if (MacroVal.hasValue())
+    return MacroVal;
+
+  // If we failed, fall-back to known values.
+  if (Ctx.getTargetInfo().getTriple().getVendor() == llvm::Triple::Apple)
+    return CachedMacroValue{0x0200};
+  return MacroVal;
+}
+
----------------
balazske wrote:

`tryExpandAsInteger` could have a version which returns a non-optional value and takes a default value or a lambda for the default value. It could be used instead of this function.

https://github.com/llvm/llvm-project/pull/127409


More information about the cfe-commits mailing list