summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-2016-123/+79
| | | | llvm-svn: 148577
* Add ability to specifiy 'restrict' on parameters of builtins, and correct ↵Ted Kremenek2012-01-201-0/+3
| | | | | | this oversight for scanf functions. llvm-svn: 148573
* Move narrowing conversion detection code from SemaInit to SemaOverload, readyRichard Smith2012-01-181-27/+38
| | | | | | | | | | | | | for it to be used in converted constant expression checking, and fix a couple of issues: - Conversion operators implicitly invoked prior to the narrowing conversion were not being correctly handled when determining whether a constant value was narrowed. - For conversions from floating-point to integral types, the diagnostic text incorrectly always claimed that the source expression was not a constant expression. llvm-svn: 148381
* A call to strlen is not a constant expression, even if we're treating it as aRichard Smith2012-01-181-1/+8
| | | | | | builtin. llvm-svn: 148374
* Constify FunctionDecl::getmemoryFunctionKind().Anna Zaks2012-01-181-1/+1
| | | | llvm-svn: 148369
* Enable constant evaluation of implicit calls to constexpr conversion operators.Richard Smith2012-01-171-1/+2
| | | | llvm-svn: 148333
* Delay the creation of the built-in Objective-C class 'Protocol' byDouglas Gregor2012-01-172-6/+15
| | | | | | | moving it from a "special type" to a predefined declaration, as we do for id, Class, and SEL. llvm-svn: 148313
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-8/+6
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-176-9/+6
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
* Use Builtin ID as the return valueAnna Zaks2012-01-171-23/+26
| | | | | | | | | | for FunctionDecl::getMemoryFunctionKind(). This is a follow up on the Chris's review for r148142: We don't want to pollute FunctionDecl with an extra enum. (To make this work, added memcmp and family to the library builtins.) llvm-svn: 148267
* Some improvements to the handling of C11 atomic types:David Chisnall2012-01-163-1/+31
| | | | | | | | | | | | | | | | | | - 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
* When deserializing the definition of a C++ class/ObjC class/ObjCDouglas Gregor2012-01-151-6/+0
| | | | | | | | | | | | | | | protocol, record the definition pointer in the canonical declaration for that entity, and then propagate that definition pointer from the canonical declaration to all other deserialized declarations. This approach works well even when deserializing declarations that didn't know about the original definition, which can occur with modules. A nice bonus from this definition-deserialization approach is that we no longer need update records when a definition is added, because the redeclaration chains ensure that the if any declaration is loaded, the definition will also get loaded. llvm-svn: 148223
* decltype(e) is type-dependent if e is instantiation-dependent. Scary but true.Richard Smith2012-01-151-1/+4
| | | | | | | Don't consider decltype(e) for an instantiation-dependent, but not type-dependent, e to be non-type-dependent but canonical(!). llvm-svn: 148210
* constexpr: casts to void* are allowed in constant expressions, don't set theRichard Smith2012-01-151-3/+3
| | | | | | | designator invalid. (Since we can't read the value of such a pointer, this only affects the quality of diagnostics.) llvm-svn: 148208
* Change linkage computation so it doesn't depend on FunctionDecl::isExternC ↵Eli Friedman2012-01-151-39/+27
| | | | | | | | or VarDecl::isExternC, and instead queries what it actually cares about: whether the given declaration is inside an extern "C" context. Fundamentally, figuring out whether a function/variable uses C linkage requires knowing the linkage, and the logic in FunctionDecl::isExternC and VarDecl::isExternC was getting it wrong. Given that, fix FunctionDecl::isExternC and VarDecl::isExternC to use much simpler implementations that depend on the fixed linkage computation. Fixes a regression to test/SemaCXX/linkage.cpp caused by a new warning exposing the fact that the internal state was wrong. llvm-svn: 148207
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-146-31/+31
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* Add a FIXME for mutation of the common pointer of a ↵Douglas Gregor2012-01-141-1/+5
| | | | | | RedeclarableTemplateDecl. It is not clear that it's worth delaying the allocation of said pointer llvm-svn: 148182
* Reimplement RedeclarableTemplateDecl in terms ofDouglas Gregor2012-01-141-33/+21
| | | | | | | | | | | Redeclarable<RedeclarableTemplateDecl>, eliminating a bunch of redeclaration-chain logic both in RedeclarableTemplateDecl and especially in its (de-)serialization. As part of this, eliminate the RedeclarableTemplate<> class template, which was an abstraction that didn't actually save anything. llvm-svn: 148181
* constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,Richard Smith2012-01-143-10/+40
| | | | | | | | | | | | | | | | | | | | APValue::Array and APValue::MemberPointer. All APValue values can now be emitted as constants. Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other entrypoints dealing with constant member pointers are no longer necessary and will be removed in a later change. Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to VarDecl::evaluateValue. This performs caching and deals with the nasty cases in C++11 where a non-const object's initializer can refer indirectly to previously-initialized fields within the same object. Building the intermediate APValue object incurs a measurable performance hit on pathological testcases with huge initializer lists, so we continue to build IR directly from the Expr nodes for array and record types outside of C++11. llvm-svn: 148178
* Remember if a type has its visibility set explicitly or implicitly.Rafael Espindola2012-01-142-48/+53
| | | | | | | | With that, centralize the way we merge visibility, always preferring explicit over implicit and then picking the most restrictive one. Fixes pr10113 and pr11690. llvm-svn: 148163
* Fix a silly mistake in ComplexExprEvaluator::ZeroInitialization. ↵Eli Friedman2012-01-131-1/+1
| | | | | | <rdar://problem/10691092>. llvm-svn: 148157
* Move identification of memory setting and copying functions (memset,Anna Zaks2012-01-131-0/+77
| | | | | | | memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic could be reused in the analyzer. llvm-svn: 148142
* Recommit r148056 with fixes to deal with weirdness with bitfields in unions.Eli Friedman2012-01-121-4/+4
| | | | | | Original message: Make sure adding a field to a struct never reduces its size. PR11745. llvm-svn: 148070
* Revert r148056 while I investigate failures.Eli Friedman2012-01-121-4/+5
| | | | llvm-svn: 148068
* Make sure adding a field to a struct never reduces its size. PR11745.Eli Friedman2012-01-121-5/+4
| | | | llvm-svn: 148056
* If an ObjCMessageExpr is implicit, there are no source locations for theArgyrios Kyrtzidis2012-01-121-3/+5
| | | | | | | | selector identifiers. It was difficult to form a test case for it unfortunately. llvm-svn: 148053
* constexpr: initialization of a union from an empty initializer-list shouldRichard Smith2012-01-121-8/+23
| | | | | | | | | zero-initialize the first union member. Also fix a bug where initializing an array of types compatible with wchar_t from a wide string literal failed in C, and fortify the C++ tests in this area. This part can't be tested without a code change to enable array evaluation in C (where an existing test fails). llvm-svn: 148035
* Allow constant-folding of references which were formed in a manner not permittedRichard Smith2012-01-121-10/+6
| | | | | | in a constant expression, for compatibility with g++. llvm-svn: 148020
* Add IsImplicit field in ObjCMessageExpr that is true when the messageArgyrios Kyrtzidis2012-01-121-19/+45
| | | | | | | | | | was constructed, e.g. for a property access. This allows the selector identifier locations machinery for ObjCMessageExpr to function correctly, in that there are not real locations to handle/report for such a message. llvm-svn: 148013
* constexpr: fix typo resulting in move constructors sometimes not beingRichard Smith2012-01-111-2/+2
| | | | | | implicitly marked constexpr when they should be. llvm-svn: 147955
* Add field IsIEEE in FloatingLiteral to distinguish between different 128-bitAkira Hatanaka2012-01-101-1/+1
| | | | | | floating point formats. llvm-svn: 147887
* Implement the missing pieces of Evaluate for _Complex types. With that ↵Eli Friedman2012-01-102-7/+43
| | | | | | complete, remove some code from CGExprConstant which is no longer necessary. While I'm here, a couple minor tweaks to _Complex-in-C++. (Specifically, make _Complex types literal types, and don't warn for _Complex int.) llvm-svn: 147840
* PR11724: Implement evaluation for constexpr defaulted trivial union copy/moveRichard Smith2012-01-101-2/+16
| | | | | | | constructors. These are a special case whose behavior cannot be modeled as a user-written constructor. llvm-svn: 147839
* Implement redeclaration merging for namespaces defined in distinctDouglas Gregor2012-01-091-5/+8
| | | | | | | | | modules. Teach name lookup into namespaces to search in each of the merged DeclContexts as well as the (now-primary) DeclContext. This supports the common case where two different modules put something into the same namespace. llvm-svn: 147778
* Pack UsingDecl more.Benjamin Kramer2012-01-071-6/+7
| | | | | | 88 -> 80 bytes on x86_64. llvm-svn: 147736
* Switch NamespaceDecl from its own hand-rolled redeclaration chain overDouglas Gregor2012-01-073-22/+42
| | | | | | | | | | | | to Redeclarable<NamespaceDecl>, so that we benefit from the improveed redeclaration deserialization and merging logic provided by Redeclarable<T>. Otherwise, no functionality change. As a drive-by fix, collapse the "inline" bit into the low bit of the original namespace/anonymous namespace, saving 8 bytes per NamespaceDecl on x86_64. llvm-svn: 147729
* More lambda work: semantic analysis of capturing 'this'. It's a bit ↵Eli Friedman2012-01-071-2/+2
| | | | | | complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.) llvm-svn: 147723
* Revert r147664; it's breaking clang regression tests.Eli Friedman2012-01-061-2/+2
| | | | llvm-svn: 147681
* Silence GCC warnings.Jakub Staszak2012-01-061-2/+2
| | | | llvm-svn: 147664
* Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bitsDouglas Gregor2012-01-061-10/+10
| | | | | | | | into the two unused lower bits of the NextDeclInContext link, dropping the number of bits in Decl down to 32, and saving 8 bytes per declaration on x86-64. llvm-svn: 147660
* C++11 generalized constant expressions: implement checking and diagnostics forRichard Smith2012-01-061-229/+317
| | | | | | | pointer-arithmetic-related undefined behavior and unspecified results. We continue to fold such values, but now notice they aren't constant expressions. llvm-svn: 147659
* Fix the mangling of class template arguments in a particularJohn McCall2012-01-061-2/+17
| | | | | | dependent case. Thanks to Jason Merrill for pointing this out. llvm-svn: 147653
* Address Richard's review comments on r147561 (Evaluate support for ↵Eli Friedman2012-01-051-5/+9
| | | | | | address-of-label differences). llvm-svn: 147631
* Always allocate an extra 8 bytes for a deserialized declaration, sinceDouglas Gregor2012-01-051-8/+5
| | | | | | some code in Clang expects 8-byte alignment of declarations. llvm-svn: 147626
* When we deserialize a declaration from a module file, allocate extraDouglas Gregor2012-01-051-1/+14
| | | | | | | | | | | | | | | storage for the global declaration ID. Declarations that are parsed (rather than deserialized) are unaffected, so the number of declarations that pay this cost tends to be relatively small (since relatively few declarations are ever deserialized). This replaces a largish DenseMap within the AST reader. It's not strictly a win in terms of memory use---not every declaration was added to that DenseMap in the first place---but it's cleaner to have this information available for every deserialized declaration, so that future clients can rely on it. llvm-svn: 147617
* When creating declarations that are deserialized from an module file,Douglas Gregor2012-01-056-61/+337
| | | | | | | go through a central allocation routine Decl::AllocateDeserializedDecl(). No actual functionality change (yet). llvm-svn: 147614
* The value of a const weak variable is not an integer constant.John McCall2012-01-051-0/+4
| | | | llvm-svn: 147575
* Add an APValue representation for the difference between two ↵Eli Friedman2012-01-043-28/+62
| | | | | | | | | | address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer. With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary. Fixes PR11705. llvm-svn: 147561
* Get rid of an unnecessary check; the AST for init-lists is the same ↵Eli Friedman2012-01-031-6/+4
| | | | | | independent of whether we're in C++11 mode. llvm-svn: 147503
* Test "merging" of typedef types across distinct modules. At present,Douglas Gregor2012-01-031-0/+6
| | | | | | | | | | | | the AST reader doesn't actually perform a merge, because name lookup knows how to merge identical typedefs together. As part of this, teach C/Objective-C name lookup to return multiple results in all cases, rather than first digging through the attributes to see if the value is overloadable. This way, we'll catch ambiguous lookups in C/Objective-C. llvm-svn: 147498
OpenPOWER on IntegriCloud