Commit Graph

450 Commits

Author SHA1 Message Date
NAKAMURA Takumi d7512b347a clang/test: Drop "REQUIRES:shell" in three tests. They can run on win32.
llvm-svn: 173419
2013-01-25 06:02:11 +00:00
Argyrios Kyrtzidis 1ffbc3a92a [PCH] Temporarily disable the "ambiguous macro" warning that is currently bogus with a PCH
that redefined a macro without undef'ing it first.

Proper reconstruction of the macro info history from modules will properly fix this in subsequent commits.

rdar://13016031

llvm-svn: 173281
2013-01-23 18:21:56 +00:00
Tim Northover 178723a687 Switch to APFloat constructor taking fltSemantics.
This change also makes the serialisation store the required semantics,
fixing an issue where PPC128 was always assumed when re-reading a
128-bit value.

llvm-svn: 173139
2013-01-22 09:46:51 +00:00
Guy Benyei 1b4fb3e08b Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
llvm-svn: 172973
2013-01-20 12:31:11 +00:00
Douglas Gregor 6a7cb9f8bc Revert Clang r172620 and r172629, which caused a hang when building
complicated modules (<rdar://problem/13038265>). Unfortunately, this
un-fixes <rdar://problem/13016031>.

llvm-svn: 172783
2013-01-18 04:34:14 +00:00
Argyrios Kyrtzidis f40f67af43 [PCH/Modules] Change how macro [re]definitions are de/serialized.
Previously we would serialize the macro redefinitions as a list, part of
the identifier, and try to chain them together across modules individually
without having the info that they were already chained at definition time.

Change this by serializing the macro redefinition chain and then try
to synthesize the chain parts across modules. This allows us to correctly
pinpoint when 2 different definitions are ambiguous because they came from
unrelated modules.

Fixes bogus "ambiguous expansion of macro" warning when a macro in a PCH
is redefined without undef'ing it first.

rdar://13016031

llvm-svn: 172620
2013-01-16 16:19:38 +00:00
Alexander Kornienko 90ff607894 Implement AST dumper for Decls.
http://llvm-reviews.chandlerc.com/D52

Patch by Philip Craig!

llvm-svn: 170634
2012-12-20 02:09:13 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
NAKAMURA Takumi e981508811 clang/test: Suppress two tests on win32 for now, since, not sure, in r169829 to r169831.
"ansi-escape-sequences" is easy convenient to exclude win32. Please be patient.

llvm-svn: 169945
2012-12-12 00:51:38 +00:00
Douglas Gregor 16ba5ff712 Try to fix Win32 failures
llvm-svn: 169923
2012-12-11 22:31:46 +00:00
Richard Smith 6b02d46dae Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
2012-12-08 08:32:28 +00:00
Richard Smith b958980cec Looks like lit on Windows can't cope with parens here, and in any case, we shouldn't need them after r169441.
llvm-svn: 169442
2012-12-05 22:59:28 +00:00
Richard Smith 48f244ac2c More workarounds for PR10867.
llvm-svn: 169437
2012-12-05 22:33:14 +00:00
Richard Smith 1c33fe8fea Store on the CXXRecordDecl whether the class has, or would have, a copy
constructor/assignment operator with a const-qualified parameter type. The
prior method for determining this incorrectly used overload resolution.

llvm-svn: 168775
2012-11-28 06:23:12 +00:00
Argyrios Kyrtzidis a660ae4421 [PCH] Reading expressions from attributes should be done using ReadExpr(),
not ReadExpr().

Also add a test case making sure the thread safety attributes work as expected
when they come from a PCH.

Fixes rdar://12584141 & http://llvm.org/PR13982

llvm-svn: 168017
2012-11-15 01:31:39 +00:00
Argyrios Kyrtzidis 243d82345d Copy the decls returned by DeclContext::lookup_result to a
new container so we can safely iterate over them.

The container holding the lookup decls can under certain conditions
be changed while iterating (e.g. because of deserialization).

llvm-svn: 167816
2012-11-13 05:07:23 +00:00
Argyrios Kyrtzidis a1c27eb8dd [PCH] Write out the ClassTemplateDecl::Common::InjectedClassNameType type
reference instead of relying on computing it.

In general, if storage is no issue, it is preferable to deserialize info from
the PCH instead of trying to recompute it after the PCH was loaded.

The incentive to change this now was due to r155303 changing how friend template
classes in dependent contexts are handled; such classes can now be chained to
a previous template class but the computed InjectedClassNameType may be different
due to the extra template parameters from the dependent context.

The new handling requires more investigation but, in the meantime, writing out
InjectedClassNameType fixes PCH issue in rdar://12627738.

llvm-svn: 167425
2012-11-06 00:35:02 +00:00
Matt Beaumont-Gay 825b9ad2fb Our style for diagnostic messages is to not include a trailing dot.
llvm-svn: 167379
2012-11-05 05:32:00 +00:00
Argyrios Kyrtzidis d7c16b2543 [PCH] Remove the stat cache from the PCH file.
The stat cache became essentially useless ever since we started
validating all file entries in the PCH.
But the motivating reason for removing it now is that it also affected
correctness in this situation:

-You have a header without include guards (using "#pragma once" or #import)
-When creating the PCH:
  -The same header is referenced in an #include with different filename cases.
  -In the PCH, of course, we record only one file entry for the header file
  -But we cache in the PCH file the stat info for both filename cases

-Then the source files are updated and the header file is updated in a way that
 its size and modification time are the same but its inode changes

-When using the PCH:
  -We validate the headers, we check that header file and we create a file entry with its current inode
  -There's another #include with a filename with different case than the previously created file entry
  -In order to get its stat info we go through the cached stat info of the PCH and we receive the old inode
  -because of the different inodes, we think they are different files so we go ahead and include its contents.

Removing the stat cache will potentially break clients that are attempting to use the stat cache
as a way of avoiding having the actual input files available. If that use case is important, patches are welcome
to bring it back in a way that will actually work correctly (i.e., emit a PCH that is self-contained, coping with
literal strings, line/column computations, etc.).

This fixes rdar://5502805

llvm-svn: 167172
2012-10-31 20:59:50 +00:00
Argyrios Kyrtzidis efaa54a5a8 [PCH] The diagnostic state points can refer to previously created
diagnostic states; make sure the ASTReader sets the diagnostic state
properly instead of always recreating it.

Fixes rdar://12581618 & http://llvm.org/PR14181

llvm-svn: 166987
2012-10-30 00:27:21 +00:00
Kaelyn Uhrain f1ecb7c62c Move the input files for test/PCH/badpch.c under test/PCH/Inputs/.
llvm-svn: 166711
2012-10-25 19:43:57 +00:00
David Tweed d8bb236e18 Correct test inovocations to use %clang_cc1 rather than direct invocation (so that it can have additional options set when trying to debug issues causing regressions).
llvm-svn: 166681
2012-10-25 13:56:30 +00:00
Douglas Gregor b636875196 Teach the PCH validator to check the preprocessor options, especially
the macros that are #define'd or #undef'd on the command line. This
checking happens much earlier than the current macro-definition
checking and is far cleaner, because it does a direct comparison
rather than a diff of the predefines buffers. Moreover, it allows us
to use the result of this check to skip over PCH files within a
directory that have non-matching -D's or -U's on the command
line. Finally, it improves the diagnostics a bit for mismatches,
fixing <rdar://problem/8612222>.

The old predefines-buffer diff'ing will go away in a subsequent commit.

llvm-svn: 166641
2012-10-24 23:41:50 +00:00
Douglas Gregor 360d3a5b06 Explicitly specify C++98 when building the C++ precompiled header for this test, so that the test will work on Windows.
llvm-svn: 166601
2012-10-24 17:49:01 +00:00
NAKAMURA Takumi 660489c49f clang/test/PCH/pch-dir.c: Update a comment for msvc. msvc(*-win32) implies -std=c++11.
llvm-svn: 166478
2012-10-23 10:43:00 +00:00
NAKAMURA Takumi 500d87159b clang/test/PCH/pch-dir.c: Mark it as XFAIL:msvc. It doesn't fail (virtually xpass) on msvc.
llvm-svn: 166473
2012-10-23 07:47:51 +00:00
NAKAMURA Takumi 0a08aa91d5 clang/test/PCH/pch-dir.c: Relax expressions of path separators for Win32.
llvm-svn: 166471
2012-10-23 07:01:50 +00:00
Douglas Gregor fc9e7a2969 If the precompiled header named by "-include" is actually a directory,
check each of the files within that directory to determine if any of
them is an AST file that matches the language and target options. If
so, the first matching AST file is loaded. This fixes a longstanding
discrepency with GCC's precompiled header implementation.

llvm-svn: 166469
2012-10-23 06:18:24 +00:00
Andy Gibbs c6e68daac0 Prior to adding the new "expected-no-diagnostics" directive to VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive.
llvm-svn: 166280
2012-10-19 12:44:48 +00:00
Douglas Gregor 72be390e13 Move the set of files to be validated in an AST file into the control
block, so the input files are validated early on, before we've
committed to loading the AST file. This (accidentally) fixed a but
wherein the main file used to generate the AST file would *not* be
validated by the existing validation logic.

At the moment, this leads to some duplication of filenames between the
source manager block and input-file blocks, as well as validation
logic. This will be handled via an upcoming patch.

llvm-svn: 166251
2012-10-19 00:38:02 +00:00
Richard Smith b6626748c2 DR1442: In a range-based for statement, namespace 'std' is not an associated
namespace.

llvm-svn: 166194
2012-10-18 17:56:02 +00:00
Douglas Gregor cb177f15e7 Serialize TargetOptions into an AST file, and make sure that we keep
target options around so they can be accessed at any point (rather
than keeping them transient).

llvm-svn: 166072
2012-10-16 23:40:58 +00:00
Douglas Gregor cb28f9d7ad Rework the (de-)serialization of macros, as stored in
MacroInfo*. Instead of simply dumping an offset into the current file,
give each macro definition a proper ID with all of the standard
modules-remapping facilities. Additionally, when a macro is modified
in a subsequent AST file (e.g., #undef'ing a macro loaded from another
module or from a precompiled header), provide a macro update record
rather than rewriting the entire macro definition. This gives us
greater consistency with the way we handle declarations, and ties
together macro definitions much more cleanly.

Note that we're still not actually deserializing macro history (we
never were), but it's far easy to do properly now.

llvm-svn: 165560
2012-10-09 23:05:51 +00:00
Alexander Kornienko 2d4f311642 Added a test for C++11 statement attributes serialization.
Summary: Uses [[clang::fallthrough]] attribute in a template function, and -Wimplicit-fallthrough to check the attribute presence in an instantiation.

Reviewers: rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D55

llvm-svn: 165068
2012-10-02 23:11:53 +00:00
Douglas Gregor 12cda633be Serialize the 'IsConstexpr' bit of VarDecls. Fixes <rdar://problem/12328814>.
llvm-svn: 164335
2012-09-20 23:43:29 +00:00
Eli Friedman 21530f7c4e Fix abbreviation for CharacterLiteral in AST serialization. PR13806.
llvm-svn: 163863
2012-09-14 00:51:36 +00:00
NAKAMURA Takumi efbb1ab92a clang/test/PCH/missing-file.cpp: Try to suppress accidental false on Windows.
%t.h might be touched by scanners as a hot file on Windows, to fail to remove %.h with single run.

llvm-svn: 163697
2012-09-12 10:38:08 +00:00
Richard Smith b15fe3a5e4 PR13811: Add a FunctionParmPackExpr node to handle references to function
parameter packs where the reference is not being expanded but the pack has
been. Previously, Clang would segfault in such cases.

llvm-svn: 163672
2012-09-12 00:56:43 +00:00
Argyrios Kyrtzidis f89a92702f [PCH] When loading fields from external storage make sure to also
load in the IndirectField declarations as well.

Field designators in initializer lists depend on traversing the fields
decl chain to find the indirect fields.

Fixes rdar://12239321

llvm-svn: 163552
2012-09-10 22:04:22 +00:00
Richard Smith 1fde8ece37 PR9023: A template template parameter whose template parameter list contains an
unexpanded parameter pack is a pack expansion. Thus, as with a non-type template
parameter which is a pack expansion, it needs to be expanded early into a fixed
list of template parameters.

Since the expanded list of template parameters is not itself a parameter pack,
it is permitted to appear before the end of the template parameter list, so also
remove that restriction (for both template template parameter pack expansions and
non-type template parameter pack expansions).

llvm-svn: 163369
2012-09-07 02:06:42 +00:00
NAKAMURA Takumi 2538bf111e test/PCH/objc_stmts.m: Suppress stderr to be fed to FileCheck.
llvm-svn: 160720
2012-07-25 11:14:11 +00:00
Ted Kremenek 875a402dc3 Turn -Wobjc-root-class on by default. <rdar://problem/11203649>.
llvm-svn: 160707
2012-07-25 07:26:32 +00:00
Aaron Ballman 462bb9fdf6 Rolling this change back because the fix doesn't fit the symptoms (even if it solves them).
llvm-svn: 160462
2012-07-18 22:38:11 +00:00
Aaron Ballman 68777ac253 Fixing up a test case that was failing due to the lack of -std=c++11
llvm-svn: 160455
2012-07-18 21:56:43 +00:00
Jordan Rose b13eb8dca5 Allow -verify directives to be filtered by preprocessing.
This is accomplished by making VerifyDiagnosticsConsumer a CommentHandler,
which then only reads the -verify directives that are actually in live
blocks of code. It also makes it simpler to handle -verify directives that
appear in header files, though we still have to manually reparse some files
depending on how they are generated.

This requires some test changes. In particular, all PCH tests now have their
-verify directives outside the "header" portion of the file, using the @line
syntax added in r159978. Other tests have been modified mostly to make it
clear what is being tested, and to prevent polluting the expected output with
the directives themselves.

Patch by Andy Gibbs! (with slight modifications)

The new Frontend/verify-* tests exercise the functionality of this commit,
as well as r159978, r159979, and r160053 (Andy's other -verify enhancements).

llvm-svn: 160068
2012-07-11 19:58:23 +00:00
Argyrios Kyrtzidis 442dd80715 [PCH] Make sure that all newly introduced visible decls in a DeclContext
coming from an AST file are registered for serialization.

A static data member instantiation of in a chained PCH could be missed
when serializing decls; the result was that when emitting the visible decls
map of its DeclContext, we would use a DeclID that was not actually emitted,
leading to crashes or hangs.

Fix this by making sure such decls are always registered for serialization.
Also introduce extra sanity checks to make sure we don't register new
declarations or types after we have serialized the types/decls block.

rdar://11728990

llvm-svn: 159550
2012-07-02 19:19:01 +00:00
Meador Inge cfb6090912 PR13189: va_list broken with precompiled headers
For some targets a structure named __va_list_tag is built to help define
the __builtin_va_list type.  However, __va_list_tag was not being treated as a
predefined type thus causing problems when serializing the AST.  This commit
fixes that oversight by adding the necessary support to treat __va_list_tag
as a predefined type.

llvm-svn: 159508
2012-07-01 15:57:25 +00:00
Douglas Gregor 3f568c100e Patch for handling C99 veriadic macros when using precompiled headers,
from Filipe Cabecinhas!

llvm-svn: 159446
2012-06-29 18:27:59 +00:00
Kaelyn Uhrain 272d718808 Add the PCH file name to the message about not being able to read the PCH.
Also add a couple of unit tests to check the invalid-PCH error messages
to satisfy PR4568 and for the assertion (introduced in r149918 and fixed
in r158769) that would cause clang to crash when given an empty PCH.

llvm-svn: 158772
2012-06-20 00:36:03 +00:00
Meador Inge 5d3fb22bac Explicitly build __builtin_va_list.
The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

llvm-svn: 158592
2012-06-16 03:34:49 +00:00
Richard Smith 2b013185f8 PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.

llvm-svn: 158288
2012-06-10 03:12:00 +00:00
Jordan Rose ccf43ca05c Add pedantic warning -Wempty-translation-unit (C11 6.9p1).
In standard C since C89, a 'translation-unit' is syntactically defined to have
at least one "external-declaration", which is either a decl or a function
definition. In Clang the latter gives us a declaration as well.

The tricky bit about this warning is that our predefines can contain external
declarations (__builtin_va_list and the 128-bit integer types). Therefore our
AST parser now makes sure we have at least one declaration that doesn't come
from the predefines buffer.

Also, remove bogus warning about empty source files. This doesn't catch source
files that only contain comments, and never fired anyway because of our
predefines.

PR12665 and <rdar://problem/9165548>

llvm-svn: 158085
2012-06-06 17:25:21 +00:00
David Blaikie 7555b6a4e5 Improve some of the conversion warnings to fire on conversion to bool.
Moves the bool bail-out down a little in SemaChecking - so now
-Wnull-conversion and -Wliteral-conversion can fire when the target type is
bool.

Also improve the wording/details in the -Wliteral-conversion warning to match
the -Wconstant-conversion.

llvm-svn: 156826
2012-05-15 16:56:36 +00:00
Argyrios Kyrtzidis 45f5118248 The Lexer constructor expects a source location at the start of the
file buffer, not at the start of lexing.

Fixes assertion hit in format diagnostics. rdar://11418366

llvm-svn: 156647
2012-05-11 21:39:18 +00:00
NAKAMURA Takumi dcb0e394a9 test/PCH/remap-file-from-pch.cpp: Fix expression for DOS pathsep.
llvm-svn: 156153
2012-05-04 03:42:28 +00:00
Argyrios Kyrtzidis 0f7d7ab968 [PCH] Really, pinky swear, fix for PR12689
rdar://11353109

llvm-svn: 156145
2012-05-04 01:49:36 +00:00
Argyrios Kyrtzidis 6eec06d0d4 [PCH] When validating that the files coming from PCH did not change, also
validate that we didn't override the contents of any of such files.

If this is detected, emit a diagnostic error and recover gracefully
by using the contents of the original file that the PCH was built from.

Part of rdar://11305263

llvm-svn: 156107
2012-05-03 21:50:39 +00:00
Argyrios Kyrtzidis 2a5deff59d [PCH] Clear switch case IDs when deserializing a objc method body.
Fixes rdar://11353109 & http://llvm.org/bugs/show_bug.cgi?id=12689

llvm-svn: 156056
2012-05-03 02:26:32 +00:00
Richard Smith e85e176600 PR12585: When processing a friend template inside a class template, don't
pretend there was no previous declaration -- that can lead us to injecting
a class template (with no access specifier) into a class scope. Instead,
just avoid the problematic checks.

llvm-svn: 155303
2012-04-22 02:13:50 +00:00
Richard Smith 8b987a9976 Fix serialization of uninstantiated exception specifications. Patch by Li Kan,
test by me.

llvm-svn: 155289
2012-04-21 17:47:47 +00:00
Nick Lewycky 2bd0ab2b11 Implement the all_lookups_iterator for PCH as a follow-up to r153970. This
includes a patch from Matthias Kleine with a regression testcase!

Adds a new iterator 'data_iterator' to OnDiskHashTable which doesn't try to
reconstruct the external_key from the internal_key, which is useful for traits
that don't store enough information to do that mapping in their key. Also
deletes the 'item_iterator' from OnDiskHashTable as dead code.

llvm-svn: 154784
2012-04-16 02:51:46 +00:00
Patrick Beard acfbe9e1f2 Added a new attribute, objc_root_class, which informs the compiler when a root class is intentionally declared.
The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger
the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698>

llvm-svn: 154187
2012-04-06 18:12:22 +00:00
David Blaikie 09ffc9b473 Enable warn_impcast_literal_float_to_integer by default.
This diagnostic seems to be production ready, it's just an oversight that it
wasn't turned on by default.

The test changes are a bit of a mixed bag. Some tests that seemed like they
clearly didn't need to use this behavior have been modified not to use it.
Others that I couldn't be sure about, I added the necessary expected-warnings
to.

It's possible the diagnostic message could be improved to make it clearer that
this warning can be suppressed by using a value that won't lose precision when
converted to the target type (but can still be a floating point literal, such
as "bool b = 1.0;").

llvm-svn: 154068
2012-04-05 00:16:44 +00:00
Douglas Gregor 6a37784a35 Eliminate obvious use-after-free. Fixes PR12433 / <rdar://problem/11168333>.
llvm-svn: 153982
2012-04-04 00:34:49 +00:00
Douglas Gregor 9f21889a7d Canonicalize the declaration we write to a PCH file for an
InjectedClassNameType; otherwise, it won't be properly wired to the
original (canonical) declaration when it is deserialized. Fixes
<rdar://problem/11112464>.

llvm-svn: 153442
2012-03-26 15:52:37 +00:00
Argyrios Kyrtzidis bf6c3395db [PCH] When we are replacing a decl in a chained PCH that is also a DeclContext,
make sure to fully load its external lexical and visible declarations before
re-writing it.

rdar://10914192

llvm-svn: 153254
2012-03-22 16:08:04 +00:00
Richard Smith 4b38ded66a Instantiating a class template should not instantiate the definition of any
scoped enumeration members. Later uses of an enumeration temploid as a nested
name specifier should cause its instantiation. Plus some groundwork for
explicit specialization of member enumerations of class templates.

llvm-svn: 152750
2012-03-14 23:13:10 +00:00
Richard Smith c67fdd4eb9 AST representation for user-defined literals, plus just enough of semantic
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
2012-03-07 08:35:16 +00:00
Ted Kremenek e65b086e07 Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
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
2012-03-06 20:05:56 +00:00
Argyrios Kyrtzidis 5cb4760aed [PCH] Include a darwin-only PCH test on Cocoa.h.
llvm-svn: 151668
2012-02-28 23:39:20 +00:00
Richard Smith 561fb15801 Teach CXXRecordDecl::hasIrrelevantDestructor to check the base classes and
data members for deleted or user-provided destructors.

Now it's computed in advance, serialize it, and in passing fix all the other
record DefinitionData flags whose serialization was missing.

llvm-svn: 151441
2012-02-25 07:33:38 +00:00
Douglas Gregor 29c42f2a25 Implement a new type trait __is_trivially_constructible(T, Args...)
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
2012-02-24 07:38:34 +00:00
Fariborz Jahanian 86f8266b9f objective-c++: Type of an objc string literal is NSString, not 'id'.
// rdar://10907410

llvm-svn: 151296
2012-02-23 22:51:36 +00:00
Douglas Gregor ed90df3800 Generate an AST for the conversion from a lambda closure type to a
block pointer that returns a block literal which captures (by copy)
the lambda closure itself. Some aspects of the block literal are left
unspecified, namely the capture variable (which doesn't actually
exist) and the body (which will be filled in by IRgen because it can't
be written as an AST).

Because we're switching to this model, this patch also eliminates
tracking the copy-initialization expression for the block capture of
the conversion function, since that information is now embedded in the
synthesized block literal. -1 side tables FTW.

llvm-svn: 151131
2012-02-22 05:02:47 +00:00
Douglas Gregor caf4826e2e Deserialize the direct-initialization range of a "new" expression
properly. Previously, we deserialized it but failed to set the
corresponding member in CXXNewExpr. Fixes <rdar://problem/10893600>.

llvm-svn: 150963
2012-02-20 16:12:14 +00:00
Douglas Gregor d3b672c385 Implicitly define a lambda's conversion functions (to function
pointers and block pointers). We use dummy definitions to keep the
invariant that an implicit, used definition has a body; IR generation
will substitute the actual contents, since they can't be represented
as C++. 

For the block pointer case, compute the copy-initialization needed to
capture the lambda object in the block, which IR generation will need
later.

llvm-svn: 150645
2012-02-16 01:06:16 +00:00
Douglas Gregor ae64101e49 Simplify and robustify lambda PCH test
llvm-svn: 150493
2012-02-14 18:47:12 +00:00
Douglas Gregor 99ae806aff Implement AST (de-)serialization for lambda expressions.
llvm-svn: 150491
2012-02-14 17:54:36 +00:00
Richard Smith 5e580292ac Track whether a function type has a trailing return type as type sugar. Use this
to pretty-print such function types better, and to fix a case where we were not
instantiating templates in lexical order. In passing, move the Variadic bit from
Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits.
Also ensure that we always substitute the return type of a function when
substituting explicitly-specified arguments, since that can cause us to bail
out with a SFINAE error before we hit a hard error in parameter substitution.

llvm-svn: 150241
2012-02-10 09:58:53 +00:00
Argyrios Kyrtzidis cee840fa92 [PCH] Add a PCH test.
llvm-svn: 150192
2012-02-09 18:31:19 +00:00
Sebastian Pop 422377cfd3 rename -ccc-host-triple into -target
llvm-svn: 148582
2012-01-20 22:01:23 +00:00
Eli Friedman d749c6bf2e Revert r148138; it's causing test failures.
llvm-svn: 148141
2012-01-13 21:33:06 +00:00
Sebastian Pop 9a8d528ddf rename -ccc-host-triple into -target
llvm-svn: 148138
2012-01-13 20:37:02 +00:00
Richard Smith ed2974f3cf C++ constant expression handling: eagerly instantiate static const integral data
members of class templates so that their values can be used in ICEs. This
required reverting r105465, to get such instantiated members to be included in
serialized ASTs.

llvm-svn: 147023
2011-12-21 00:25:33 +00:00
Fariborz Jahanian f9aca2089e objc-arc: bridge casts in non-arc mode are now
error. // rdar://10597832

llvm-svn: 146918
2011-12-19 22:52:53 +00:00
Richard Smith d0b4dd656d constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'
variable is initialized by a non-constant expression, and pass in the variable
being declared so that earlier-initialized fields' values can be used.

Rearrange VarDecl init evaluation to make this possible, and in so doing fix a
long-standing issue in our C++ constant expression handling, where we would
mishandle cases like:

  extern const int a;
  const int n = a;
  const int a = 5;
  int arr[n];

Here, n is not initialized by a constant expression, so can't be used in an ICE,
even though the initialization expression would be an ICE if it appeared later
in the TU. This requires computing whether the initializer is an ICE eagerly,
and saving that information in PCH files.

llvm-svn: 146856
2011-12-19 06:19:21 +00:00
Douglas Gregor 05f10357a9 Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.

The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed). 

As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.

This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.

llvm-svn: 146841
2011-12-17 23:38:30 +00:00
Argyrios Kyrtzidis f76e13e9ea [PCH] Remove extraneous line in the test that was mistakenly copied.
No functionality change.

llvm-svn: 146825
2011-12-17 08:11:28 +00:00
Argyrios Kyrtzidis 2072fbd775 [PCH] Fix bug where we failed to update an identifier for a single token
macro expansion.

rdar://10588825

llvm-svn: 146818
2011-12-17 04:13:31 +00:00
Richard Trieu 553b2b2e5d Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared.  If either is a substring of the other, then
no error is given.  This gives rise to an unexpected case:

  // expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

  candidate function has different number of parameters (expected 1 but has 2)
  candidate function has different number of parameters

It will also match these other error messages:

  candidate function
  function has different number of parameters
  number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting.  Also, all the failing tests from this
change have been corrected.  Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)

llvm-svn: 146619
2011-12-15 00:38:15 +00:00
Argyrios Kyrtzidis b9e53ed4e2 [PCH] In ASTReader::FinishedDeserializing, after we do PassInterestingDeclsToConsumer
we may end up having added more pending stuff to do, so go in a loop until everything
is cleared out.

This fixes the error in rdar://10278815 which has a certain David Lynch-esque quality..

  error: unknown type name 'BOOL'; did you mean 'BOOL'?

llvm-svn: 145536
2011-11-30 23:18:26 +00:00
Argyrios Kyrtzidis 5938650b13 [PCH] When serializing an PseudoObjectExpr or AtomicExpr, the serialization code must be set
otherwise it will crash with asserts on or it will be written as null pointer.

llvm-svn: 144626
2011-11-15 06:20:27 +00:00
Argyrios Kyrtzidis 846e61a363 [PCH] Do not crash if a class extension in a chained PCH introduces/redeclares a property.
llvm-svn: 144520
2011-11-14 04:52:29 +00:00
Argyrios Kyrtzidis f9d0f4744e [PCH] Fix the test.
llvm-svn: 144467
2011-11-12 21:07:54 +00:00
Argyrios Kyrtzidis b97a4025ff [PCH] When completing an objc forward reference, do not serialize the chain of its categories because
it is going to be rewritten (and the chain will be serialized again), otherwise we may form a cycle in its
categories list when deserializing.

Also introduce ASTMutationListener::CompletedObjCForwardRef to notify that a forward reference
was completed; using Decl's isChangedSinceDeserialization/setChangedSinceDeserialization
is bug inducing and kinda gross, we should phase it out.

Fixes infinite loop in rdar://10418538.

llvm-svn: 144465
2011-11-12 21:07:46 +00:00
Chandler Carruth 996cb8ad84 This test was assuming that /usr/include was in the system header search
path. That assumption should never have been true, but it was until
I fixed it. Now that its fixed, add a triple here to get correct
behavior even on Windows.

llvm-svn: 143863
2011-11-06 06:59:15 +00:00
Chandler Carruth e3fcb6981f Switch these two tests to use the Clang driver instead of CC1. They want
to do "realistic" includes, and so need the header search logic now in
the driver. This in turn requires switching the CC1 options to the
actual driver options, and passing -Xclang where there is no analogy.

llvm-svn: 143805
2011-11-05 10:15:30 +00:00
Argyrios Kyrtzidis 6fb6003aad [PCH] Now that we store the location of a decl outside its record
make sure that we keep track of locations of replaced decls as well.

llvm-svn: 143341
2011-10-31 07:20:15 +00:00