r256524 - Small refactoring in CheckerContext::isCLibraryFunction(). NFC.

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 28 13:47:51 PST 2015


Author: dcoughlin
Date: Mon Dec 28 15:47:51 2015
New Revision: 256524

URL: http://llvm.org/viewvc/llvm-project?rev=256524&view=rev
Log:
Small refactoring in CheckerContext::isCLibraryFunction(). NFC.

Use getRedeclContext() instead of a manually-written loop and fix a comment.

A patch by Aleksei Sidorin!

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

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp?rev=256524&r1=256523&r2=256524&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp Mon Dec 28 15:47:51 2015
@@ -57,12 +57,8 @@ bool CheckerContext::isCLibraryFunction(
     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.




More information about the cfe-commits mailing list