Arquivos
hhvm/hphp/compiler/expression/constant_expression.h
T
Todd Nowacki adda9a5022 HPHP Changes for Clang
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
2013-06-25 13:19:03 -07:00

95 linhas
3.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_CONSTANT_EXPRESSION_H_
#define incl_HPHP_CONSTANT_EXPRESSION_H_
#include "hphp/compiler/expression/expression.h"
#define CONSTANT(value) makeConstant(ar, value)
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
DECLARE_BOOST_TYPES(ConstantExpression);
class ConstantExpression : public Expression, IParseHandler {
public:
ConstantExpression(EXPRESSION_CONSTRUCTOR_PARAMETERS,
const std::string &name,
bool hadBackslash,
const std::string &docComment = "");
DECLARE_BASE_EXPRESSION_VIRTUAL_FUNCTIONS;
void onParse(AnalysisResultConstPtr ar, FileScopePtr scope);
ExpressionPtr preOptimize(AnalysisResultConstPtr ar);
virtual bool isTemporary() const {
return isNull() || isBoolean();
}
virtual bool isScalar() const;
virtual bool isLiteralNull() const;
virtual int getLocalEffects() const { return NoEffect; }
virtual bool getScalarValue(Variant &value);
virtual bool containsDynamicConstant(AnalysisResultPtr ar) const {
return !m_valid || m_dynamic;
}
virtual unsigned getCanonHash() const;
virtual bool canonCompare(ExpressionPtr e) const;
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);
}
const std::string &getDocComment() const {
return m_docComment;
}
bool isNull() const;
bool isBoolean() const;
bool isDouble() const;
bool getBooleanValue() const;
void pushConst(const std::string &name);
void popConst();
void setComment(const std::string &comment) { m_comment = comment;}
std::string getComment() { return m_comment;}
bool isValid() const { return m_valid; }
bool isDynamic() const { return m_dynamic; }
bool hadBackslash() const { return m_hadBackslash; }
private:
Symbol *resolveNS(AnalysisResultConstPtr ar);
std::string m_name;
std::string m_origName;
bool m_hadBackslash;
std::string m_docComment;
std::string m_comment; // for inlined constant name
bool m_valid;
bool m_dynamic;
bool m_visited;
bool m_depsSet;
};
///////////////////////////////////////////////////////////////////////////////
}
#endif // incl_HPHP_CONSTANT_EXPRESSION_H_