adda9a5022
More changes for HPHP to help make it clang friendly ~~~hphp/compiler/expression/constant_expression.h ~~~hphp/compiler/expression/function_call.h rfind returns a size_t/unsigned int ~~~hphp/runtime/base/server/http_protocol.cpp Switched to std::to_string. Assuming [] was not intended here ~~~hphp/runtime/base/ref_data.h These fields were accessed in a public manner, assuming public was intended instead of private ~~~hphp/runtime/base/variable_serializer.cpp Switched to using [] and & to make clang happy. Assuming this was to either take or drop the first char. ~~~hphp/runtime/ext/asio/asio_external_thread_event_queue.h ~~~hphp/runtime/ext/asio/asio_external_thread_event_queue.cpp Cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression. This is been moved to a macro as a temporary fix. +++hphp/runtime/ext/ext_misc.cpp Added std::atomic to supress warnings ~~~hphp/runtime/vm/jit/simplifier.cpp Chosen constructor is explicit in copy-initialization ~~~hphp/runtime/vm/jit/translator-asm-helpers.S Ambiguous instructions require an explicit suffix Changed cmp to cmpl ~~~hphp/runtime/vm/jit/translator-x64-helpers.cpp Clang does not support global register variables +++hphp/runtime/vm/unwind.cpp describeFault was only used when DEBUG or USE_TRACE was defined ~~~hphp/runtime/vm/verifier/check_unit.cpp Made fmt pointer const to avoid string format issues/warnings ~~~hphp/util/stack_trace.cpp Clang does not support variable-length arrays. Uniqe_ptr is used instead to take advantage runtime-sized arrays, a restriced form of variable-length arrays ~~~hphp/util/thread_local.h Clang seems to be supporting the __thread attribute, or at the very least it is not complaining about it. ~~~hphp/util/tiny_vector.h Clang does not like the flexible array here, since T is not always POD. I have reimplemented the array here by just sticking one value in the struct and calculating the offset from its address manually. Alterinatively, we could change the the non-POD types to be pointers, or we could edit their implemenations. +++hphp/util/util.h Created a template for the union, A function declared with the constexpr specifier cannot contain type declarations that do not define classes or enumerations +++hphp/runtime/vm/jit/x64-util.h Added a TODO The way hphp/runtime/vm/jit/x64-util.h is currently implemented, it only works if USE_GCC_FAST_TLS is defined
121 linhas
4.4 KiB
C++
121 linhas
4.4 KiB
C++
/*
|
|
+----------------------------------------------------------------------+
|
|
| HipHop for PHP |
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| http://www.php.net/license/3_01.txt |
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
|
|
#ifndef incl_HPHP_FUNCTION_CALL_H_
|
|
#define incl_HPHP_FUNCTION_CALL_H_
|
|
|
|
#include "hphp/compiler/analysis/function_scope.h"
|
|
#include "hphp/compiler/expression/static_class_name.h"
|
|
|
|
namespace HPHP {
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
DECLARE_BOOST_TYPES(ExpressionList);
|
|
DECLARE_BOOST_TYPES(FunctionScope);
|
|
DECLARE_BOOST_TYPES(FunctionCall);
|
|
|
|
class FunctionCall : public Expression, public StaticClassName {
|
|
protected:
|
|
FunctionCall(EXPRESSION_CONSTRUCTOR_BASE_PARAMETERS, ExpressionPtr nameExp,
|
|
const std::string &name, bool hadBackslash,
|
|
ExpressionListPtr params, ExpressionPtr classExp);
|
|
public:
|
|
void analyzeProgram(AnalysisResultPtr ar);
|
|
|
|
virtual bool isRefable(bool checkError = false) const { return true;}
|
|
virtual bool isTemporary() const;
|
|
|
|
virtual ConstructPtr getNthKid(int n) const;
|
|
virtual void setNthKid(int n, ConstructPtr cp);
|
|
virtual int getKidCount() const;
|
|
|
|
virtual ExpressionPtr preOptimize(AnalysisResultConstPtr ar);
|
|
virtual ExpressionPtr postOptimize(AnalysisResultConstPtr ar);
|
|
|
|
const std::string &getName() const { return m_name; }
|
|
const std::string &getOriginalName() const { return m_origName; }
|
|
const std::string getNonNSOriginalName() const {
|
|
auto nsPos = m_origName.rfind('\\');
|
|
if (nsPos == string::npos) {
|
|
return m_origName;
|
|
}
|
|
return m_origName.substr(nsPos + 1);
|
|
}
|
|
ExpressionPtr getNameExp() const { return m_nameExp; }
|
|
const ExpressionListPtr& getParams() const { return m_params; }
|
|
void setNoInline() { m_noInline = true; }
|
|
void deepCopy(FunctionCallPtr exp);
|
|
|
|
FunctionScopeRawPtr getFuncScope() const { return m_funcScope; }
|
|
bool canInvokeFewArgs();
|
|
void setArrayParams() { m_arrayParams = true; }
|
|
bool isValid() const { return m_valid; }
|
|
bool hadBackslash() const { return m_hadBackslash; }
|
|
|
|
protected:
|
|
ExpressionPtr m_nameExp;
|
|
std::string m_name;
|
|
std::string m_origName;
|
|
int m_ciTemp;
|
|
int m_clsNameTemp;
|
|
ExpressionListPtr m_params;
|
|
|
|
// Pointers to the corresponding function scope and class scope for this
|
|
// function call, set during the AnalyzeAll phase. These pointers may be
|
|
// null if the function scope or class scope could not be resolved.
|
|
FunctionScopeRawPtr m_funcScope;
|
|
ClassScopeRawPtr m_classScope;
|
|
|
|
bool m_valid;
|
|
int m_extraArg;
|
|
unsigned m_variableArgument : 1;
|
|
unsigned m_voidReturn : 1; // no return type
|
|
unsigned m_voidWrapper : 1; // void wrapper is needed
|
|
unsigned m_redeclared : 1;
|
|
unsigned m_noStatic : 1;
|
|
unsigned m_noInline : 1;
|
|
unsigned m_invokeFewArgsDecision : 1;
|
|
unsigned m_arrayParams : 1;
|
|
bool m_hadBackslash;
|
|
|
|
// Extra arguments form an array, to which the scalar array optimization
|
|
// should also apply.
|
|
int m_argArrayId;
|
|
int m_argArrayHash;
|
|
int m_argArrayIndex;
|
|
void optimizeArgArray(AnalysisResultPtr ar);
|
|
|
|
void markRefParams(FunctionScopePtr func, const std::string &name,
|
|
bool canInvokeFewArgs);
|
|
|
|
/**
|
|
* Each program needs to reset this object's members to revalidate
|
|
* a function call.
|
|
*/
|
|
void reset();
|
|
|
|
TypePtr checkParamsAndReturn(AnalysisResultPtr ar, TypePtr type,
|
|
bool coerce, FunctionScopePtr func,
|
|
bool arrayParams);
|
|
|
|
ExpressionPtr inliner(AnalysisResultConstPtr ar,
|
|
ExpressionPtr obj, std::string localThis);
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
}
|
|
#endif // incl_HPHP_FUNCTION_CALL_H_
|