]> granicus.if.org Git - clang/commitdiff
Small refactoring in CheckerContext::isCLibraryFunction(). NFC.
authorDevin Coughlin <dcoughlin@apple.com>
Mon, 28 Dec 2015 21:47:51 +0000 (21:47 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Mon, 28 Dec 2015 21:47:51 +0000 (21:47 +0000)
Use getRedeclContext() instead of a manually-written loop and fix a comment.

A patch by Aleksei Sidorin!

Differential Revision: http://reviews.llvm.org/D15794

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256524 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/CheckerContext.cpp

index 37b2564a81f09f28d9a09a6106e1d5926207cedb..5ec8bfa800744ed2db3cca2ab59010f3f2c29de1 100644 (file)
@@ -57,12 +57,8 @@ bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
     return false;
 
   // Look through 'extern "C"' and anything similar invented in the future.
-  const DeclContext *DC = FD->getDeclContext();
-  while (DC->isTransparentContext())
-    DC = DC->getParent();
-
-  // If this function is in a namespace, it is not a C library function.
-  if (!DC->isTranslationUnit())
+  // If this function is not in TU directly, it is not a C library function.
+  if (!FD->getDeclContext()->getRedeclContext()->isTranslationUnit())
     return false;
 
   // If this function is not externally visible, it is not a C library function.