=?utf-8?q?Balázs_Kéri?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -1054,10 +1054,26 @@ const VarRegion *MemRegionManager::getVarRegion(const
VarDecl *D,
assert(!Ty.isNull());
if (Ty.isConstQualified()) {
sReg = getGlobalsRegion(MemRegion::GlobalImmutableSpaceRegionKind);
- } else if (Ctx.getSourceManager().isInSystemHeader(D->getLocation())) {
- sReg = getGlobalsRegion(MemRegion::GlobalSystemSpaceRegionKind);
} else {
- sReg = getGlobalsRegion(MemRegion::GlobalInternalSpaceRegionKind);
+ StringRef N = D->getNameAsString();
+ QualType FILETy = D->getASTContext().getFILEType();
+ if (!FILETy.isNull())
+ FILETy = FILETy.getCanonicalType();
+ Ty = Ty.getCanonicalType();
+ bool IsStdStreamVar = Ty->isPointerType() &&
+ Ty->getPointeeType() == FILETy &&
+ (N == "stdin" || N == "stdout" || N == "stderr");
+ // Pointer value of C standard streams is usually not modified by calls
+ // to functions declared in system headers. This means that they should
+ // not get invalidated by calls to functions declared in system headers,
+ // so they are placed in the global internal space, which is not
+ // invalidated by calls to functions declared in system headers.
+ if (Ctx.getSourceManager().isInSystemHeader(D->getLocation()) &&
+ !IsStdStreamVar) {
+ sReg = getGlobalsRegion(MemRegion::GlobalSystemSpaceRegionKind);
+ } else {
+ sReg = getGlobalsRegion(MemRegion::GlobalInternalSpaceRegionKind);
+ }
----------------
steakhal wrote:
I'm not challenging this.
https://github.com/llvm/llvm-project/pull/147766
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits