summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Silva <silvas@purdue.edu>2012-10-11 23:31:18 +0000
committerSean Silva <silvas@purdue.edu>2012-10-11 23:31:18 +0000
commit886e7f8cbb45eed3381aaaca80098473259768cf (patch)
tree9ae6e4d6ece3a63de76745fb759085b3b2bba450
parentd7802ad8a5fa05a386597a09c32543804e4c8edd (diff)
downloadbcm5719-llvm-886e7f8cbb45eed3381aaaca80098473259768cf.tar.gz
bcm5719-llvm-886e7f8cbb45eed3381aaaca80098473259768cf.zip
Add missing classof().
Somewhat troublingly, without this implemented, the check inside isa_impl<> would silently use the parent's `classof()` when determining whether it was okay to downcast from the parent to the child! Bug analysis: A build failure after removing the parent's `classof()` initially alerted me to the bug, after which a little bit of thinking and reading of the code identified the root cause. The compiler could be made to prevent this bug from happening if there were a way to ensure that in the code template <typename To, typename From, typename Enabler = void> struct isa_impl { static inline bool doit(const From &Val) { return To::classof(&Val); } }; that `To::classof` is actually inside the class `To`, and not in a base class. I am not aware of a way to check this in C++. If there is a means to perform that check, please bring it up on the list and this will be fixed. There is a high likelihood that there are other instances of this same bug in the codebase. llvm-svn: 165769
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
index b5ed00316f4..9003a226363 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -399,6 +399,10 @@ public:
virtual void flattenLocations() { Pos.flatten(); }
virtual void Profile(llvm::FoldingSetNodeID &ID) const;
+
+ static bool classof(const PathDiagnosticPiece *P) {
+ return P->getKind() == Event || P->getKind() == Macro;
+ }
};
/// \brief Interface for classes constructing Stack hints.
OpenPOWER on IntegriCloud