diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2017-01-10 18:49:27 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2017-01-10 18:49:27 +0000 |
commit | dc9834f91269c73702b6f0d7e428d169508a1386 (patch) | |
tree | 11ad9d780b3c5919cda17d42d5a50445650981e8 /clang/lib | |
parent | 3a6474ecbba47ae8916f2d8e48d2b098055b93d7 (diff) | |
download | bcm5719-llvm-dc9834f91269c73702b6f0d7e428d169508a1386.tar.gz bcm5719-llvm-dc9834f91269c73702b6f0d7e428d169508a1386.zip |
[analyzer] Treat pointers to static member functions as function pointers
Sema treats pointers to static member functions as having function pointer
type, so treat treat them as function pointer values in the analyzer as well.
This prevents an assertion failure in SValBuilder::evalBinOp caused by code
that expects function pointers to be Locs (in contrast, PointerToMember values
are nonlocs).
Differential Revision: https://reviews.llvm.org/D28033
llvm-svn: 291581
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/SValBuilder.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp index 10b0858b848..ffaa0eda918 100644 --- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -218,6 +218,18 @@ SValBuilder::getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, } DefinedSVal SValBuilder::getMemberPointer(const DeclaratorDecl* DD) { + assert(!DD || isa<CXXMethodDecl>(DD) || isa<FieldDecl>(DD)); + + if (auto *MD = dyn_cast_or_null<CXXMethodDecl>(DD)) { + // Sema treats pointers to static member functions as have function pointer + // type, so return a function pointer for the method. + // We don't need to play a similar trick for static member fields + // because these are represented as plain VarDecls and not FieldDecls + // in the AST. + if (MD->isStatic()) + return getFunctionPointer(MD); + } + return nonloc::PointerToMember(DD); } |