summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-03-06 00:18:21 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-03-06 00:18:21 +0000
commit15e814f687e42c3bc41e6454c86087eb3373d39f (patch)
treef3173d34e4b5e47d81c8a8f3c9cd61ec46c1ca03 /clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
parent39e54cb7b750b6d95214299bae309b5e07e23835 (diff)
downloadbcm5719-llvm-15e814f687e42c3bc41e6454c86087eb3373d39f.tar.gz
bcm5719-llvm-15e814f687e42c3bc41e6454c86087eb3373d39f.zip
[analyzer] [quickfix] Prevent a crash in NamedDecl::getName()
llvm-svn: 326755
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
index 48e9e1e7625..23ef032bb05 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
@@ -88,9 +88,11 @@ void GCDAsyncSemaphoreChecker::checkASTCodeBody(const Decl *D,
BugReporter &BR) const {
// The pattern is very common in tests, and it is OK to use it there.
- if (const auto* ND = dyn_cast<NamedDecl>(D))
- if (ND->getName().startswith("test"))
+ if (const auto* ND = dyn_cast<NamedDecl>(D)) {
+ std::string DeclName = ND->getNameAsString();
+ if (StringRef(DeclName).startswith("test"))
return;
+ }
const char *SemaphoreBinding = "semaphore_name";
auto SemaphoreCreateM = callExpr(callsName("dispatch_semaphore_create"));
OpenPOWER on IntegriCloud