]> granicus.if.org Git - clang/commitdiff
Teach GRExprEngine::VisitLValue() about FloatingLiteral, ImaginaryLiteral, and Charac...
authorTed Kremenek <kremenek@apple.com>
Thu, 29 Jul 2010 01:31:59 +0000 (01:31 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 29 Jul 2010 01:31:59 +0000 (01:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109719 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/GRExprEngine.cpp
test/Analysis/misc-ps-region-store.cpp

index 73fc9262605940ce905130fd3db21d8d173f6320..9ee723eb7c5446fc7d3e3875447746b5a70c0e51 100644 (file)
@@ -1058,6 +1058,9 @@ void GRExprEngine::VisitLValue(const Expr* Ex, ExplodedNode* Pred,
     // In C++, binding an rvalue to a reference requires to create an object.
     case Stmt::CXXBoolLiteralExprClass:
     case Stmt::IntegerLiteralClass:
+    case Stmt::CharacterLiteralClass:
+    case Stmt::FloatingLiteralClass:
+    case Stmt::ImaginaryLiteralClass:
       CreateCXXTemporaryObject(Ex, Pred, Dst);
       return;
 
index 6794d481d68b2cf89488110b60aa51bf8db4c453..baaa2f6cbd071a6564518b8dea36de0bb9e1f38e 100644 (file)
@@ -132,3 +132,19 @@ int TestHandleThis::null_deref_positive() {
   return 0;  
 }
 
+// PR 7675 - passing literals by-reference
+void pr7675(const double &a);
+void pr7675(const int &a);
+void pr7675(const char &a);
+void pr7675_i(const _Complex double &a);
+
+void pr7675_test() {
+  pr7675(10.0);
+  pr7675(10);
+  pr7675('c');
+  pr7675_i(4.0i);
+  // Add null deref to ensure we are analyzing the code up to this point.
+  int *p = 0;
+  *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+}
+