[PATCH] D69272: Enable '#pragma STDC FENV_ACCESS' in frontend

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 6 13:48:51 PST 2020


rjmccall added inline comments.


================
Comment at: clang/lib/Sema/SemaStmt.cpp:386
+  if (FPFeatures.allowFEnvAccess()) {
+    FunctionDecl *F = getCurFunctionDecl();
+    F->setUsesFPIntrin(true);
----------------
There isn't necessarily a current function declaration; this is usable in blocks, ObjC methods, etc.  It's even usable in global initializers because of statement-expressions. An attribute is really a much more flexible way of setting this information.

Sema has a concept of the current function scope; I think you should probably track this bit there and then copy that as appropriate to the FunctionDecl / ObjCMethodDecl / BlockDecl / lambda invocation function / whatever when the function body is done.

You should also handle templates, which means you'll need to set the FPOptions in the current function scope to the appropriate baseline when starting to instantiate a function definition.  constexpr-if means you can't just propagate the bit from the template.  I would suggest a rule where, for template patterns, the attribute is used solely to represent the baseline rather than whether the function actually contains any local pragmas.  Or maybe you already need to record the baseline for the outermost scope?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69272





More information about the cfe-commits mailing list