diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2013-05-29 20:50:34 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2013-05-29 20:50:34 +0000 |
| commit | 1bd1927a142089b7c0121102950163df5cc8ba13 (patch) | |
| tree | 2ccbe10cf6c6a4532c64ec3db65fea34046836d2 /clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | |
| parent | 33b736626ea4bd12738f8893b1b8cdc663f9c2e0 (diff) | |
| download | bcm5719-llvm-1bd1927a142089b7c0121102950163df5cc8ba13.tar.gz bcm5719-llvm-1bd1927a142089b7c0121102950163df5cc8ba13.zip | |
[analyzer] Accept references to variables declared "extern void" (C only).
In C, 'void' is treated like any other incomplete type, and though it is
never completed, you can cast the address of a void-typed variable to do
something useful. (In C++ it's illegal to declare a variable with void type.)
Previously we asserted on this code; now we just treat it like any other
incomplete type.
And speaking of incomplete types, we don't know their extent. Actually
check that in TypedValueRegion::getExtent, though that's not being used
by any checkers that are on by default.
llvm-svn: 182880
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngine.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index bfe4e15a715..627e0107b86 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1613,7 +1613,9 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D, const LocationContext *LCtx = Pred->getLocationContext(); if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { - assert(Ex->isGLValue()); + // C permits "extern void v", and if you cast the address to a valid type, + // you can even do things with it. We simply pretend + assert(Ex->isGLValue() || VD->getType()->isVoidType()); SVal V = state->getLValue(VD, Pred->getLocationContext()); // For references, the 'lvalue' is the pointer address stored in the |

