summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
* there i fixed itAlexis Hunt2011-05-042-9/+46
| | | | | | | | | Increase robustness of the delegating constructor cycle detection mechanism. No more infinite loops on invalid or logic errors leading to false results. Ensure that this is maintained correctly accross serialization. llvm-svn: 130887
* Implement serialization of delegating constructors.Alexis Hunt2011-05-042-15/+31
| | | | llvm-svn: 130822
* Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),Douglas Gregor2011-05-042-2/+4
| | | | | | | | which determines whether a particular file is actually a header that is intended to be guarded from multiple inclusions within the same translation unit. llvm-svn: 130808
* Revise the representation of parameter scope data so that theJohn McCall2011-05-022-3/+14
| | | | | | | scope depth overlaps with the ObjCDeclQualifier, dropping memory usage back to previous levels. llvm-svn: 130671
* Add an optional field attached to a DeclRefExpr which points back to theChandler Carruth2011-05-012-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decl actually found via name lookup & overload resolution when that Decl is different from the ValueDecl which is actually referenced by the expression. This can be used by AST consumers to correctly attribute references to the spelling location of a using declaration, and otherwise gain insight into the name resolution performed by Clang. The public interface to DRE is kept as narrow as possible: we provide a getFoundDecl() which always returns a NamedDecl, either the ValueDecl referenced or the new, more precise NamedDecl if present. This way AST clients can code against getFoundDecl without know when exactly the AST has a split representation. For an example of the data this provides consider: % cat x.cc namespace N1 { struct S {}; void f(const S&); } void test(N1::S s) { f(s); using N1::f; f(s); } % ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc [...] void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1> (CallExpr 0x5b01df0 <line:6:3, col:6> 'void' (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)')) (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))) (DeclStmt 0x5b01ee0 <line:7:3, col:14> 0x5b01e40 "UsingN1::;") (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void' (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f'))) (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))) Now we can tell that the second call is 'using' (no pun intended) the using declaration, and *which* using declaration it sees. Without this, we can mistake calls that go through using declarations for ADL calls, and have no way to attribute names looked up with using declarations to the appropriate UsingDecl. llvm-svn: 130670
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-012-0/+6
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Remove the NameQualifier struct, which was just a wrapper aroundChandler Carruth2011-05-011-1/+1
| | | | | | | | | NestedNameSpecifierLoc. It predates when we had such an object. Reference the NNSLoc directly in DREs, and embed it directly into the MemberNameQualifier struct. llvm-svn: 130668
* Several cosmetic changes, no functionality changed.Chandler Carruth2011-05-011-1/+1
| | | | | | | | | | Mostly trailing whitespace so that me editor nuking it doesn't muddy the waters of subsequent commits that do change functionality. Also nukes a stray statement that was harmless but redundant that I introduced in r130666. llvm-svn: 130667
* Move the state bits in DeclRefExpr out of the pointer union and intoChandler Carruth2011-05-011-9/+5
| | | | | | | | | | | | | | | a bitfield in the base class. DREs weren't using any bits here past the normal Expr bits, so we have plenty of room. This makes the common case of getting a Decl out of a DRE no longer need to do any masking etc. Also, while here, clean up code to use the accessor methods rather than directly poking these bits, and provide a nice comment for DREs that includes the information previously attached to the bits going into the pointer union. No functionality changed here, but DREs should be a tad faster now. llvm-svn: 130666
* Compress some bits. Only matters for MSVC, or if we everJohn McCall2011-05-011-10/+10
| | | | | | | devirtualize Decl (because bits can't get laid out in base classes if the base is POD). llvm-svn: 130632
* Re-applies the patch first applied way back in r106099, withChandler Carruth2011-05-014-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | accompanying fixes to make it work today. The core of this patch is to provide a link from a TemplateTypeParmType back to the TemplateTypeParmDecl node which declared it. This in turn provides much more precise information about the type, where it came from, and how it functions for AST consumers. To make the patch work almost a year after its first attempt, it needed serialization support, and it now retains the old getName() interface. Finally, it requires us to not attempt to instantiate the type in an unsupported friend decl -- specifically those coming from template friend decls but which refer to a specific type through a dependent name. A cleaner representation of the last item would be to build FriendTemplateDecl nodes for these, storing their template parameters etc, and to perform proper instantation of them like any other template declaration. They can still be flagged as unsupported for the purpose of access checking, etc. This passed an asserts-enabled bootstrap for me, and the reduced test case mentioned in the original review thread no longer causes issues, likely fixed at somewhere amidst the 24k revisions that have elapsed. llvm-svn: 130628
* Rename the last '[hH]asStandardLayout' entites to '[iI]sStandardLayout'Chandler Carruth2011-04-302-2/+2
| | | | | | | based on Doug's preferences when we discussed this in IRC. This brings the wording more in line with the standard. llvm-svn: 130603
* Completely re-implement the core logic behind the __is_standard_layoutChandler Carruth2011-04-302-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type trait. The previous implementation suffered from several problems: 1) It implemented all of the logic in RecordType by walking over every base and field in a CXXRecordDecl and validating the constraints of the standard. This made for very straightforward code, but is extremely inefficient. It also is conceptually wrong, the logic tied to the C++ definition of standard-layout classes should be in CXXRecordDecl, not RecordType. 2) To address the performance problems with #1, a cache bit was added to CXXRecordDecl, and at the completion of every C++ class, the RecordType was queried to determine if it was a standard layout class, and that state was cached. Two things went very very wrong with this. First, the caching version of the query *was never called*. Even within the recursive steps of the walk over all fields and bases the caching variant was not called, making each query a full *recursive* walk. Second, despite the cache not being used, it was computed for every class declared, even when the trait was never used in the program. This probably significantly regressed compile time performance for edge-case files. 3) An ASTContext was required merely to query the type trait because querying it performed the actual computations. 4) The caching bit wasn't managed correctly (uninitialized). The new implementation follows the system for all the other traits on C++ classes by encoding all the state needed in the definition data and building up the trait incrementally as each base and member are added to the definition of the class. The idiosyncracies of the specification of standard-layout classes requires more state than I would like; currently 5 bits. I could eliminate one of the bits easily at the expense of both clarity and resilience of the code. I might be able to eliminate one of the other bits by computing its state in terms of other state bits in the definition. I've already done that in one place where there was a fairly simple way to achieve it. It's possible some of the bits could be moved out of the definition data and into some other structure which isn't serialized if the serialized bloat is a problem. That would preclude serialization of a partial class declaration, but that's likely already precluded. Comments on any of these issues welcome. llvm-svn: 130601
* Serialize/deserialize the HasStandardLayout bit when writing/reading PCHs.Anders Carlsson2011-04-292-0/+2
| | | | llvm-svn: 130525
* Add a decl update when a static data member of a class template is ↵Sebastian Redl2011-04-293-4/+24
| | | | | | instantiated in a different PCH than its containing class. Otherwise we get double definition errors. Fixes a Boost.MPL problem that affects Boost.Accumulators and probably a lot more of Boost. llvm-svn: 130488
* Enhance clang_getCXTUResourceUsage() to report the sizes of the memory ↵Ted Kremenek2011-04-282-0/+27
| | | | | | buffers used by PCH. llvm-svn: 130460
* Implementation of Embarcadero array type traitsJohn Wiegley2011-04-282-0/+25
| | | | | | | | | | 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
* If a null statement was preceded by an empty macro keep its instantiation ↵Argyrios Kyrtzidis2011-04-272-2/+2
| | | | | | | | source location in NullStmt. llvm-svn: 130289
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-262-0/+2
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* Fix a crash when ASTReader emits diagnostic when another one is in flight. ↵Argyrios Kyrtzidis2011-04-251-4/+11
| | | | | | Fixes rdar//9334563. llvm-svn: 130162
* t/clang/expr-traitsJohn Wiegley2011-04-252-0/+25
| | | | | | | | | 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
* Use template magic to make dumping of vectors slightly less fragile.Benjamin Kramer2011-04-241-27/+18
| | | | | | No intended functionality change. llvm-svn: 130114
* Set the correct anonymous namespace (must be last reopening), and behave ↵Sebastian Redl2011-04-242-9/+16
| | | | | | correctly in the presence of the ever-annoying linkage specifications. llvm-svn: 130105
* Fix adding an anonymous namespace in a chained PCH to a namespace from a ↵Sebastian Redl2011-04-243-1/+26
| | | | | | | | previous PCH. Fix anonymous namespaces in PCH. llvm-svn: 130104
* Synthesizing the definition of an implicit member is an AST modification, so ↵Sebastian Redl2011-04-241-0/+9
| | | | | | notify any mutation listeners of it. This fixes a crasher in chained PCH, where an implicit destructor in a PCH gets a definition in a chained PCH, which is then lost. However, any further use of the destructor would cause its definition to be regenerated in the final file, hiding the bug. llvm-svn: 130103
* On reading DeclContexts from PCH, check for visible updates even if the ↵Sebastian Redl2011-04-241-14/+18
| | | | | | context was empty in the original version. Also, if there are any, tell the context that it has external visible decls. This fixes the problem that a namespace that was empty in the initial PCH (could also happen if the initial PCH didn't include any std header but caused implicit creation of namespace std, e.g. due to implicit declaration of a virtual destructor) never found any declaration declared in *any* chained PCH. Very ugly when the chained PCH includes all that std stuff, as the errors were effectively the same as not including std headers. llvm-svn: 130102
* Store the full list of pending instantiations in a chained PCH. Previously ↵Sebastian Redl2011-04-242-15/+13
| | | | | | we attempted to store only new pending instantiations, but our filter was incorrect, dropping implicit instantiations of class template members. It's just not worth coming up with a complex filter that is correct, when the only cost is PCH files that are a few hundred bytes (at most) larger. llvm-svn: 130098
* Implement most of the remaining logic in __is_literal type trait. ThisChandler Carruth2011-04-242-0/+4
| | | | | | | should now support all of the C++98 types, and all of the C++0x types Clang supports. llvm-svn: 130079
* Begin tracking trivialness of move constructors and move assignmentChandler Carruth2011-04-232-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operators in C++ record declarations. This patch starts off by updating a bunch of the standard citations to refer to the draft 0x standard so that the semantics intended for move varianst is clear. Where necessary these are duplicated so they'll be available in doxygen. It adds bit fields to keep track of the state for the move constructs, and updates all the code necessary to track this state (I think) as members are declared for a class. It also wires the state into the various trait-like accessors in the AST's API, and tests that the type trait expressions now behave correctly in the presence of move constructors and move assignment operators. This isn't complete yet due to these glaring FIXMEs: 1) No synthesis of implicit move constructors or assignment operators. 2) I don't think we correctly enforce the new logic for both copy and move trivial checks: that the *selected* copy/move constructor/operator is trivial. Currently this requires *all* of them to be trivial. 3) Some of the trait logic needs to be folded into the fine-grained trivial bits to more closely match the wording of the standard. For example, many of the places we currently set a bit to track POD-ness could be removed by querying other more fine grained traits on demand. llvm-svn: 130076
* Teach the AST reader and writer to preserve the __DEPRECATED bit inChandler Carruth2011-04-232-0/+3
| | | | | | | | | | | language options, and warn when reading an AST with a different value for the bit. There doesn't appear to be a good way to test this (commenting out similar other language options doesn't break anything) but if folks have suggestions on tests I'm happy to add them. llvm-svn: 130071
* ForArgyrios Kyrtzidis2011-04-222-10/+28
| | | | | | | | double data[20000000] = { [19999999] = 1 }; Don't serialize the filler multiple times. llvm-svn: 129983
* ForArgyrios Kyrtzidis2011-04-212-3/+11
| | | | | | | | | | | | | | double data[20000000] = {0}; we would blow out the memory by creating 20M Exprs to fill out the initializer. To fix this, if the initializer list initializes an array with more elements than there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression that specifies an expression to be used for value initialization of the rest of the elements. Fixes rdar://9275920. llvm-svn: 129896
* Teach SourceManager::getSLocEntry() that it can fail due to problemsDouglas Gregor2011-04-201-2/+2
| | | | | | | | during deserialization from a precompiled header, and update all of its callers to note when this problem occurs and recover (more) gracefully. Fixes <rdar://problem/9119249>. llvm-svn: 129839
* We regard a function as 'unused' from the codegen perspective, so our ↵Argyrios Kyrtzidis2011-04-192-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | warnings diverge from gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context (e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed is somewhat misleading. - Don't emit 'unused' warnings for functions that are referenced in any part of the user's code. - A warning that an internal function/variable won't get emitted is useful though, so introduce -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not "needed" ('used' from the codegen perspective), e.g: static void foo() { } template <int> void bar() { foo(); } test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted static void foo() { } ^ Addresses rdar://8733476. llvm-svn: 129794
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-153-6/+23
| | | | llvm-svn: 129567
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-152-3/+3
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* C1X: implement generic selectionsPeter Collingbourne2011-04-153-0/+43
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* C1X: add a language standardPeter Collingbourne2011-04-152-0/+3
| | | | llvm-svn: 129553
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-146-0/+47
| | | | | | draft standard (N3291). llvm-svn: 129541
* Chained PCH: Remember when additional specializations are added to a ↵Sebastian Redl2011-04-141-0/+12
| | | | | | function template from a previous PCH. Fixes the only crasher when using massive chains on Clang's Sema component. We still have some incomplete codegen there. llvm-svn: 129516
* The ASTReader created by -chain-include used the generated PCH buffers in ↵Sebastian Redl2011-04-141-2/+2
| | | | | | the wrong order. The effect was that all but the first chain-include files was ignored for subsequent compilations. llvm-svn: 129513
* Add a flag to StringLiteral to keep track of whether the string is a pascal ↵Anders Carlsson2011-04-142-1/+3
| | | | | | string or not. llvm-svn: 129488
* Fix AST serialization of reference-to-reference types. This previously causedRichard Smith2011-04-122-4/+5
| | | | | | | | | a crash when deserializing the AST for this: typedef char (&R); extern R &r; llvm-svn: 129358
* PR8369: make __attribute((regparm(0))) work correctly. Original patch byEli Friedman2011-04-092-5/+7
| | | | | | pageexec@freemail.hu, tweaks by me. llvm-svn: 129206
* Basic, untested implementation for an "unknown any" type requested by LLDB.John McCall2011-04-072-0/+2
| | | | | | | | | | | | The idea is that you can create a VarDecl with an unknown type, or a FunctionDecl with an unknown return type, and it will still be valid to access that object as long as you explicitly cast it at every use. I'm still going back and forth about how I want to test this effectively, but I wanted to go ahead and provide a skeletal implementation for the LLDB folks' benefit and because it also improves some diagnostic goodness for placeholder expressions. llvm-svn: 129065
* Make ChainedIncludesSource an ExternalSemaSource, otherwise initialization ↵Sebastian Redl2011-03-311-0/+15
| | | | | | of the ASTReader is incomplete, leading to errors like not realizing std::type_info is already defined. llvm-svn: 128664
* Tell the diagnostic client about starting and ending source files when ↵Sebastian Redl2011-03-311-0/+3
| | | | | | automatically creating chained PCHs. This way, we don't get a crash whenever a diagnostic is emitted while processing the include. llvm-svn: 128663
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-232-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-122-14/+20
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* Forgotten part of previous commit.Abramo Bagnara2011-03-122-4/+4
| | | | llvm-svn: 127536
OpenPOWER on IntegriCloud