0

In clang's ActOnIfStmt function, we have:

return Owned(new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr,
    thenStmt, ElseLoc, elseStmt));

I'm under the impression that Context is a pointer type, but it's a class type. How does this work, and what does this code do?

In silico
  • 51,091
  • 10
  • 150
  • 143
  • This is called ["placement new"](http://www.parashift.com/c++-faq-lite/placement-new.html), which is used to instantiate objects at a specific memory location pointed by `Context`. So `Context` is (as far as I know) in fact a pointer type. `IfStmt` is the class type here. – In silico Nov 24 '13 at 09:56
  • http://clang.llvm.org/doxygen/ASTContext_8h-source.html - look at lines 1314 and following. Doesn't look like a standard form of `operator new` (cc @Insilico). – Mat Nov 24 '13 at 09:58
  • Thank you ,Mat.i understand it now ,thank you very much! – zglieren303 Nov 24 '13 at 10:41

0 Answers0