[cfe-commits] r155693 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
Ted Kremenek
kremenek at apple.com
Thu Apr 26 21:54:29 PDT 2012
Author: kremenek
Date: Thu Apr 26 23:54:28 2012
New Revision: 155693
URL: http://llvm.org/viewvc/llvm-project?rev=155693&view=rev
Log:
Use a deque instead of an ImmutableList in AnalysisConsumer to preserve the file order that functions are visited. Should fix the buildbots.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h?rev=155693&r1=155692&r2=155693&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h Thu Apr 26 23:54:28 2012
@@ -14,15 +14,15 @@
#ifndef LLVM_CLANG_GR_FUNCTIONSUMMARY_H
#define LLVM_CLANG_GR_FUNCTIONSUMMARY_H
+#include <deque>
#include "clang/AST/Decl.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/ImmutableList.h"
namespace clang {
namespace ento {
-typedef llvm::ImmutableList<Decl*> SetOfDecls;
+typedef std::deque<Decl*> SetOfDecls;
typedef llvm::DenseSet<const Decl*> SetOfConstDecls;
class FunctionSummariesTy {
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=155693&r1=155692&r2=155693&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Thu Apr 26 23:54:28 2012
@@ -102,8 +102,6 @@
/// The local declaration to all declarations ratio might be very small when
/// working with a PCH file.
SetOfDecls LocalTUDecls;
-
- SetOfDecls::Factory LocalTUDeclsFactory;
// PD is owned by AnalysisManager.
PathDiagnosticConsumer *PD;
@@ -308,9 +306,7 @@
if (isa<ObjCMethodDecl>(*I))
continue;
- // We use an ImmutableList to avoid issues with invalidating iterators
- // to the list while we are traversing it.
- LocalTUDecls = LocalTUDeclsFactory.add(*I, LocalTUDecls);
+ LocalTUDecls.push_back(*I);
}
}
@@ -319,9 +315,6 @@
// Build the Call Graph.
CallGraph CG;
// Add all the top level declarations to the graph.
- //
- // NOTE: We use an ImmutableList to avoid issues with invalidating iterators
- // to the list while we are traversing it.
for (SetOfDecls::iterator I = LocalTUDecls.begin(),
E = LocalTUDecls.end(); I != E; ++I)
CG.addToCallGraph(*I);
@@ -410,12 +403,13 @@
// Process all the top level declarations.
//
- // NOTE: We use an ImmutableList to avoid issues with invalidating iterators
- // to the list while we are traversing it.
- //
- for (SetOfDecls::iterator I = LocalTUDecls.begin(),
- E = LocalTUDecls.end(); I != E; ++I) {
- TraverseDecl(*I);
+ // Note: TraverseDecl may modify LocalTUDecls, but only by appending more
+ // entries. Thus we don't use an iterator, but rely on LocalTUDecls
+ // random access. By doing so, we automatically compensate for iterators
+ // possibly being invalidated, although this is a bit slower.
+ const unsigned n = LocalTUDecls.size();
+ for (unsigned i = 0 ; i < n ; ++i) {
+ TraverseDecl(LocalTUDecls[i]);
}
if (Mgr->shouldInlineCall())
Modified: cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m?rev=155693&r1=155692&r2=155693&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m (original)
+++ cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m Thu Apr 26 23:54:28 2012
@@ -80,11 +80,11 @@
int marker(void) { // control reaches end of non-void function
}
+// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
More information about the cfe-commits
mailing list