summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/StmtPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix assertions and wrong output from StmtPrinter's string literal printing.Richard Smith2012-04-051-5/+46
| | | | | | | | | | String literals (including unicode ones) can contain non-Unicode codepoints if they were written using \x or similar. Write those out using \x, but be careful that the following character can't be misinterpreted as part of the \x escape sequence. Convert UTF-16 surrogate pairs back to codepoints before rendering them. llvm-svn: 154069
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-4/+0
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. llvm-svn: 152491
* Fix statement printing for raw and template user-defined literals.Richard Smith2012-03-091-6/+9
| | | | llvm-svn: 152401
* Ensure we don't print 123ULL_foo when printing a user-defined integer literal.Richard Smith2012-03-081-1/+6
| | | | llvm-svn: 152303
* AST representation for user-defined literals, plus just enough of semanticRichard Smith2012-03-071-0/+25
| | | | | | | | | | | | | | | | | | | | | analysis to make the AST representation testable. They are represented by a new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic properties, including full CodeGen support, are achieved for free by this representation. UserDefinedLiterals can never be dependent, so no custom instantiation behavior is required. They are mangled as if they were direct calls to the underlying literal operator. This matches g++'s apparent behavior (but not its actual mangling, which is broken for literal-operator-ids). User-defined *string* literals are now fully-operational, but the semantic analysis is quite hacky and needs more work. No other forms of user-defined literal are created yet, but the AST support for them is present. This patch committed after midnight because we had already hit the quota for new kinds of literal yesterday. llvm-svn: 152211
* Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,Ted Kremenek2012-03-061-0/+47
| | | | | | | | | | | | | NSNumber, and boolean literals. This includes both Sema and Codegen support. Included is also support for new Objective-C container subscripting. My apologies for the large patch. It was very difficult to break apart. The patch introduces changes to the driver as well to cause clang to link in additional runtime support when needed to support the new language features. Docs are forthcoming to document the implementation and behavior of these features. llvm-svn: 152137
* Implement a new type trait __is_trivially_constructible(T, Args...)Douglas Gregor2012-02-241-0/+17
| | | | | | | | | | | | | | | | that provides the behavior of the C++11 library trait std::is_trivially_constructible<T, Args...>, which can't be implemented purely as a library. Since __is_trivially_constructible can have zero or more arguments, I needed to add Yet Another Type Trait Expression Class, this one handling arbitrary arguments. The next step will be to migrate UnaryTypeTrait and BinaryTypeTrait over to this new, more general TypeTrait class. Fixes the Clang side of <rdar://problem/10895483> / PR12038. llvm-svn: 151352
* Provide the __is_trivially_assignable type trait, which providesDouglas Gregor2012-02-231-5/+6
| | | | | | | compiler support for the std::is_trivially_assignable library type trait. llvm-svn: 151240
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-161-11/+7
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-161-7/+11
| | | | | | | | | | used constructor itself." It leads to a compiler crash in the Bullet benchmark. This reverts commit r12014. llvm-svn: 150684
* Make CXXNewExpr contain only a single initialier, and not hold the used ↵Sebastian Redl2012-02-161-11/+7
| | | | | | | | | | constructor itself. Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. llvm-svn: 150682
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-3/+3
| | | | | | | | | | | | | | | | | | expressions. This is mostly a simple refact, splitting the main "start a lambda expression" function into smaller chunks that are driven either from the parser (Sema::ActOnLambdaExpr) or during AST transformation (TreeTransform::TransformLambdaExpr). A few minor interesting points: - Added new entry points for TreeTransform, so that we can explicitly establish the link between the lambda closure type in the template and the lambda closure type in the instantiation. - Added a bit into LambdaExpr specifying whether it had an explicit result type or not. We should have had this anyway. This code is 'lightly' tested. llvm-svn: 150417
* Print NamedDecls directly to a raw_ostream where possible.Benjamin Kramer2012-02-071-2/+2
| | | | llvm-svn: 149982
* Introduce basic ASTs for lambda expressions. This covers:Douglas Gregor2012-02-071-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | - Capturing variables by-reference and by-copy within a lambda - The representation of lambda captures - The creation of the non-static data members in the lambda class that store the captured variables - The initialization of the non-static data members from the captured variables - Pretty-printing lambda expressions There are a number of FIXMEs, both explicit and implied, including: - Creating a field for a capture of 'this' - Improved diagnostics for initialization failures when capturing variables by copy - Dealing with temporaries created during said initialization - Template instantiation - AST (de-)serialization - Binding and returning the lambda expression; turning it into a proper temporary - Lots and lots of semantic constraints - Parameter pack captures llvm-svn: 149977
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-2/+3
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-10/+11
| | | | llvm-svn: 149127
* Some improvements to the handling of C11 atomic types:David Chisnall2012-01-161-1/+5
| | | | | | | | | | | | | | | | | | - Add atomic-to/from-nonatomic cast types - Emit atomic operations for arithmetic on atomic types - Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load - Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type. This is needed for the corresponding C11 stdatomic.h function. - Enables the relevant __has_feature() checks. The feature isn't 100% complete yet, but it's done enough that we want people testing it. Still to do: - Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg. - Add a signal fence builtin - Properly set the fenv state in atomic operations on floating point values - Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context) - Fix the many remaining corner cases llvm-svn: 148242
* Add assertion to char32_t that the value is valid, as suggested by Jordy Rose.Richard Smith2012-01-021-1/+1
| | | | | | | Add a test that such characters don't make it through to StringLiteral objects in error recovery. llvm-svn: 147438
* Fix crash when trying to pretty-print unicode or wide string literals.Richard Smith2011-12-301-8/+19
| | | | llvm-svn: 147385
* Implement support for the __is_final type trait, to determine whetherDouglas Gregor2011-12-031-0/+1
| | | | | | | a class is marked 'final', from Alberto Ganesh Barbati! Fixes PR11462. llvm-svn: 145775
* Per an offline conversation with John McCall, have StmtPrinter actually ↵Ted Kremenek2011-11-301-1/+3
| | | | | | print out the source expression for OpaqueValueExpr. llvm-svn: 145524
* Add support for printing integer literals of type short, unsigned short,Richard Trieu2011-11-071-0/+7
| | | | | | | | __int128_t and __uint128_t. Short and unsigned short integer literals support is only to work around a crasher as reported in PR11179 and will be removed once Clang no longer builds short integer literals. llvm-svn: 143977
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* Implement support for dependent Microsoft __if_exists/__if_not_existsDouglas Gregor2011-10-251-0/+16
| | | | | | | | | | statements. As noted in the documentation for the AST node, the semantics of __if_exists/__if_not_exists are somewhat different from the way Visual C++ implements them, because our parsed-template representation can't accommodate VC++ semantics without serious contortions. Hopefully this implementation is "good enough". llvm-svn: 142901
* Change operator<< for raw_ostream and NamedDecl to take a reference instead ↵Benjamin Kramer2011-10-141-3/+3
| | | | | | | | of a pointer. Passing a pointer was a bad idea as it collides with the overload for void*. llvm-svn: 141971
* Silence some -Wuninitialized false positives with gcc.Eli Friedman2011-10-111-1/+1
| | | | llvm-svn: 141701
* Initial implementation of __atomic_* (everything except __atomic_is_lock_free).Eli Friedman2011-10-111-0/+53
| | | | llvm-svn: 141632
* Use APFloat::toString to print APFloats more precisely in the AST printer. ↵Eli Friedman2011-10-051-2/+3
| | | | | | Patch by Olaf Krzikalla. llvm-svn: 141208
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-3/+3
| | | | llvm-svn: 140367
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-3/+15
| | | | llvm-svn: 136210
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-7/+7
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+5
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Automatic Reference Counting.John McCall2011-06-151-0/+17
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Add support for builtin astype:Tanya Lattner2011-06-041-0/+7
| | | | | | | __builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types. Added test case. llvm-svn: 132612
* Implement the __is_trivially_copyable type traitAlexis Hunt2011-05-131-0/+1
| | | | llvm-svn: 131270
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-1/+1
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Remove a few more bogus returns when the switch covers all theChandler Carruth2011-05-011-4/+3
| | | | | | | | | enumerators. Also remove a default that led to llvm_unreachable to make another switch warn if any enumerators fail to be covered. llvm-svn: 130646
* Remove another default and a *completely* bogus return from a switchChandler Carruth2011-05-011-2/+2
| | | | | | | | over type traits. Add the missing trait from this switch that Clang's warning uncovered. llvm-svn: 130645
* Remove the type traits UTT_IsLvalueExpr and UTT_IsRvalueExpr.Chandler Carruth2011-05-011-2/+0
| | | | | | | | | | | As might be surmised from their names, these aren't type traits, they're expression traits. Amazingly enough, they're expression traits that we have, and fully implement. These "type" traits are even parsed from the same tokens as the expression traits. Luckily, the parser only tried the expression trait parsing for these tokens, so this was all just a pile of dead code. llvm-svn: 130643
* Parsing/AST support for Structured Exception HandlingJohn Wiegley2011-04-281-0/+42
| | | | | | | | Patch authored by Sohail Somani. Provide parsing and AST support for Windows structured exception handling. llvm-svn: 130366
* Implementation of Embarcadero array type traitsJohn Wiegley2011-04-281-0/+13
| | | | | | | | | | Patch authored by John Wiegley. These are array type traits used for parsing code that employs certain features of the Embarcadero C++ compiler: __array_rank(T) and __array_extent(T, Dim). llvm-svn: 130351
* t/clang/type-traitsJohn Wiegley2011-04-271-4/+31
| | | | | | | | | | Patch authored by John Wiegley. These type traits are used for parsing code that employs certain features of the Embarcadero C++ compiler. Several of these constructs are also desired by libc++, according to its project pages (such as __is_standard_layout). llvm-svn: 130342
* t/clang/expr-traitsJohn Wiegley2011-04-251-0/+15
| | | | | | | | | Patch authored by David Abrahams. These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for parsing code that employs certain features of the Embarcadero C++ compiler. llvm-svn: 130122
* Implement basic __is_trivial type-trait support, enough to close PR9472.Chandler Carruth2011-04-231-0/+1
| | | | | | | | | | | | | | | | | | This introduces a few APIs on the AST to bundle up the standard-based logic so that programmatic clients have access to exactly the same behavior. There is only one serious FIXME here: checking for non-trivial move constructors and move assignment operators. Those bits need to be added to the declaration and accessors provided. This implementation should be enough for the uses of __is_trivial in libstdc++ 4.6's C++98 library implementation. Ideas for more thorough test cases or any edge cases missing would be appreciated. =D llvm-svn: 130057
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-0/+17
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+12
| | | | | | draft standard (N3291). llvm-svn: 129541
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-111-2/+12
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
OpenPOWER on IntegriCloud