Ted Kremenek | 588e5eb | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 1 | //===--- SemaUtil.h - Utility functions for semantic analysis -------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Ted Kremenek | 588e5eb | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file provides a few static inline functions that are useful for |
| 11 | // performing semantic analysis. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_SEMA_UTIL_H |
| 16 | #define LLVM_CLANG_SEMA_UTIL_H |
| 17 | |
| 18 | #include "clang/AST/Expr.h" |
| 19 | |
| 20 | namespace clang { |
| 21 | |
Ted Kremenek | 588e5eb | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 22 | /// Utility method to determine if a CallExpr is a call to a builtin. |
| 23 | static inline bool isCallBuiltin(CallExpr* cexp) { |
Chris Lattner | 56f3494 | 2008-02-13 01:02:39 +0000 | [diff] [blame] | 24 | Expr* sub = cexp->getCallee()->IgnoreParenCasts(); |
Ted Kremenek | 588e5eb | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 25 | |
| 26 | if (DeclRefExpr* E = dyn_cast<DeclRefExpr>(sub)) |
| 27 | if (E->getDecl()->getIdentifier()->getBuiltinID() > 0) |
| 28 | return true; |
| 29 | |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | } // end namespace clang |
| 34 | |
| 35 | #endif |