aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-03-14 03:07:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-03-14 03:07:35 +0000
commit2d1b09641ecf2e754bf3fd244dc45dbf3e460c1b (patch)
treed443e248befdaaff3e66daa89d4ee4c0d87cef3e /lib/AST/Type.cpp
parentaa778f1e4f024a38cd2085f69f36ab33b98862b0 (diff)
Avoid computing the linkage too early. Don't invalidate it.
Before this patch we would compute the linkage lazily and cache it. When the AST was modified in ways that could change the value, we would invalidate the cache. That was fairly brittle, since any code could ask for the a linkage before the correct value was available. We should change the API to one where the linkage is computed explicitly and trying to get it when it is not available asserts. This patch is a first step in that direction. We still compute the linkage lazily, but instead of invalidating a cache, we assert that the AST modifications didn't change the result. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index ca086b1951..cdd67fda4f 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -2236,6 +2236,14 @@ static LinkageInfo computeLinkageInfo(QualType T) {
return computeLinkageInfo(T.getTypePtr());
}
+bool Type::isLinkageValid() const {
+ if (!TypeBits.isCacheValid())
+ return true;
+
+ return computeLinkageInfo(getCanonicalTypeInternal()).getLinkage() ==
+ TypeBits.getLinkage();
+}
+
LinkageInfo Type::getLinkageAndVisibility() const {
if (!isCanonicalUnqualified())
return computeLinkageInfo(getCanonicalTypeInternal());
@@ -2245,12 +2253,6 @@ LinkageInfo Type::getLinkageAndVisibility() const {
return LV;
}
-void Type::ClearLinkageCache() {
- TypeBits.CacheValid = false;
- if (QualType(this, 0) != CanonicalType)
- CanonicalType->TypeBits.CacheValid = false;
-}
-
Qualifiers::ObjCLifetime Type::getObjCARCImplicitLifetime() const {
if (isObjCARCImplicitlyUnretainedType())
return Qualifiers::OCL_ExplicitNone;