summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2016-12-17 01:08:17 +0000
committerDevin Coughlin <dcoughlin@apple.com>2016-12-17 01:08:17 +0000
commitaa0fd76be30cd18068345228c26f551ea3fbe093 (patch)
tree6df04a1a65e825c62ad58a6cc9287ffdafe488bd /clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
parenta4bd1463c8dc04bcd9befd49a667dbfd7fec0f87 (diff)
downloadbcm5719-llvm-aa0fd76be30cd18068345228c26f551ea3fbe093.tar.gz
bcm5719-llvm-aa0fd76be30cd18068345228c26f551ea3fbe093.zip
[analyzer] UnixAPIChecker: Don't diagnose for functions in C++ namespaces
Update the UnixAPIChecker to not diagnose for calls to functions that are declared in C++ namespaces. This avoids false positives when a namespaced function has the same name as a Unix API. This address PR28331. llvm-svn: 290023
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index 0945bbf09f5..26bf597bd95 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -427,6 +427,12 @@ void UnixAPIChecker::checkPreStmt(const CallExpr *CE,
if (!FD || FD->getKind() != Decl::Function)
return;
+ // Don't treat functions in namespaces with the same name a Unix function
+ // as a call to the Unix function.
+ const DeclContext *NamespaceCtx = FD->getEnclosingNamespaceContext();
+ if (NamespaceCtx && isa<NamespaceDecl>(NamespaceCtx))
+ return;
+
StringRef FName = C.getCalleeName(FD);
if (FName.empty())
return;
OpenPOWER on IntegriCloud