unsigned size() const { return map.size(); }
/// Returns the bit vector index for a given declaration.
- llvm::Optional<unsigned> getValueIndex(const VarDecl *d);
+ llvm::Optional<unsigned> getValueIndex(const VarDecl *d) const;
};
}
}
}
-llvm::Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) {
- llvm::DenseMap<const VarDecl *, unsigned>::iterator I = map.find(d);
+llvm::Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) const {
+ llvm::DenseMap<const VarDecl *, unsigned>::const_iterator I = map.find(d);
if (I == map.end())
return llvm::Optional<unsigned>();
return I->second;
return declToIndex.size() == 0;
}
+ bool hasEntry(const VarDecl *vd) const {
+ return declToIndex.getValueIndex(vd).hasValue();
+ }
+
void resetScratch();
ValueVector &getScratch() { return scratch; }
void BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt *fs);
bool isTrackedVar(const VarDecl *vd) {
+#if 1
+ // FIXME: This is a temporary workaround to deal with the fact
+ // that DeclContext's do not always contain all of their variables!
+ return vals.hasEntry(vd);
+#else
return ::isTrackedVar(vd, cast<DeclContext>(ac.getDecl()));
+#endif
}
FindVarResult findBlockVarDecl(Expr *ex);
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fcxx-exceptions %s -verify
int test1_aux(int &x);
int test1() {
return a; // expected-warning{{variable 'a' is possibly uninitialized when used here}}
}
+// This test previously crashed Sema.
+class Rdar9188004A {
+public:
+ virtual ~Rdar9188004A();
+};
+
+template< typename T > class Rdar9188004B : public Rdar9188004A {
+virtual double *foo(Rdar9188004B *next) const {
+ double *values = next->foo(0);
+ try {
+ }
+ catch(double e) {
+ values[0] = e;
+ }
+ return 0;
+ }
+};
+class Rdar9188004C : public Rdar9188004B<Rdar9188004A> {
+ virtual void bar(void) const;
+};
+void Rdar9188004C::bar(void) const {}