Ivan Krasin [Tue, 20 Sep 2011 14:56:54 +0000 (14:56 +0000)]
Clarify PNaCl target characteristics: set LongDoubleWidth, PtrDiffType, IntPtrType,
change __builtin_va_list to from a structure to int[4] (same alignment
and size, but with a simpler representation). Patch by David Meyer!
John McCall [Tue, 20 Sep 2011 06:21:28 +0000 (06:21 +0000)]
Fix a crash-on-invalid with bad CV-qualification on 'this' in the
presence of an implicit move assignment operator. I think the implicit
copy assignment operator case was also wrong, but just in a "displaying
the wrong diagnostic" way.
Fix a pretty nasty bug in noreturn destructors that cascaded into lots
of false positive warnings that depend on noreturn destructors pruning
the CFGs, but only in C++0x mode!
This was really surprising as the debugger quickly reveals that the
attributes are parsed correctly (and using the same code) in both modes.
The warning fires in the same way in both modes. But between parsing and
building the destructor declaration with the noreturn attribute and the
warning, it magically disappears. The key? The 'noexcept' appears!
When we were rebuilding the destructor type with the computed implicit
noexcept we completely dropped the old type on the floor. This almost
makes sense (as the arguments and return type to a destructor aren't
exactly unpredictable), but lost any function type attributes as well.
The fix is simple, we build the new type off of the old one rather than
starting fresh.
Testing this is a bit awkward. I've done it by running the
noreturn-sensitive tests in both modes, which previous failed and now
passes, but if anyone has ideas about how to more specifically and
thoroughly test that the extended info on a destructor is preserved when
adding noexcept, I'm all ears.
Anna Zaks [Tue, 20 Sep 2011 01:51:40 +0000 (01:51 +0000)]
[analyzer] Refactor PathDiagnosticLocation: Pre-compute Range and Location with gen methods on object creation instead of computing on demand. This would allow to remove dependency on the other members which help with construction and might not even be valid at later stages (to be removed later on).
Eli Friedman [Mon, 19 Sep 2011 23:17:44 +0000 (23:17 +0000)]
Add list initialization for complex numbers in C. Essentially, this allows "_Complex float x = {1.0f, 2.0f};". See changes to docs/LanguageExtensions.html for a longer description.
Bill Wendling [Mon, 19 Sep 2011 22:08:36 +0000 (22:08 +0000)]
The eh.selector intrinsic isn't used anymore. Replace the check here with a
check for the landingpad instruction instead. This check looks at each of the
clauses in the landingpad instruction. If it's a catch clause, it compares the
name directly with the global. If it's a filter clause, it has to look through
each value in the filer to see if any have the prefix.
In libclang, when visiting preprocessed entities in a source range, use
PreprocessingRecord's getPreprocessedEntitiesInRange.
Also remove all the stuff that were added in ASTUnit that are unnecessary now
that we do a binary search for preprocessed entities and deserialize only
what is necessary.
In CodeGenAction::ExecuteAction() use SourceManager::translateFileLineCol()
instead of getLocation() since we don't care about expanded macro arguments.
[libclang] When getting a source location from a file:line:col triplet
check whether the requested location points inside the precompiled preamble,
in which case the returned source location will be a "loaded" one.
Introduce PreprocessingRecord::getPreprocessedEntitiesInRange()
which will do a binary search and return a pair of iterators
for preprocessed entities in the given source range.
Source ranges of preprocessed entities are stored twice currently in
the PCH/Module file but this will be fixed in a subsequent commit.
For SourceManager::isBeforeInTranslationUnit, a location pointing
inside a macro argument should be regarded as coming before
the location of the expanded tokens.
[PCH] Preload the PreloadSLocEntries through the SourceManager and
don't call ReadSLocEntryRecord() directly because the entry may have
already been loaded in which case calling ReadSLocEntryRecord()
directly would trigger an assertion in SourceManager.
For SourceManager::isBeforeInTranslationUnit, when one location
points at the inclusion/expansion point of the other, regard this
as coming before the other.
Bill Wendling [Mon, 19 Sep 2011 20:31:14 +0000 (20:31 +0000)]
Throw the switch to convert clang to the new exception handling model!
This model uses the 'landingpad' instruction, which is pinned to the top of the
landing pad. (A landing pad is defined as the destination of the unwind branch
of an invoke instruction.) All of the information needed to generate the correct
exception handling metadata during code generation is encoded into the
landingpad instruction.
The new 'resume' instruction takes the place of the llvm.eh.resume intrinsic
call. It's lowered in much the same way as the intrinsic is.
Richard Trieu [Mon, 19 Sep 2011 19:01:00 +0000 (19:01 +0000)]
Changes to the name lookup have caused a regression in the digraph fix-it hint.
For instance:
template <class T> void E() {};
class F {};
void test() {
::E<::F>();
E<::F>();
}
Gives the following error messages:
error: found '<::' after a template name which forms the
digraph '<:' (aka '[') and a ':', did you mean '< ::'?
::E<::F>();
^~~
< ::
error: expected expression
E<::F>();
^
error: expected ']'
note: to match this '['
E<::F>();
This patch adds the digraph fix-it check right before the name lookup,
moves the shared checking code to a new function, and adds new
tests to catch future regressions.
Fix a QoI bug with overloaded operators inside macros.
We were failing to set source locations and ranges in isUnusedResultAWarning
for CXXOperatorCallExprs, leading to an "expression result unused" warning
with absolutely no context if the expression was inside a macro.
In Microsoft mode(-fms-compatibility), prefer an integral conversion to a floating-to-integral conversion if the integral conversion is between types of the same size.
For example:
void f(float);
void f(int);
int main {
long a;
f(a);
}
Here, MSVC will call f(int) instead of generating a compile error as clang will do in standard mode.
This fixes a few errors when parsing MFC code with clang.
Richard Smith [Sun, 18 Sep 2011 12:11:43 +0000 (12:11 +0000)]
PR10304: Do not call destructors for data members from union destructors. Prior to C++11, this
has no effect since any such destructors must be trivial, and in C++11 such destructors must not
be called.
Richard Smith [Sun, 18 Sep 2011 11:14:50 +0000 (11:14 +0000)]
PR10954: variant members should not be implicitly initialized in constructors if no
mem-initializer is specified for them, unless an in-class initializer is specified.
Richard Smith [Sun, 18 Sep 2011 00:06:34 +0000 (00:06 +0000)]
Fix PR10531. Attach an initializer to anonymous unions, since the default constructor might not be trivial (if there is an in-class initializer for some member) and might be deleted.
Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag.
Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag.
Douglas Gregor [Sat, 17 Sep 2011 05:35:18 +0000 (05:35 +0000)]
When we load header file information from the external source (i.e.,
the AST reader), merge that header file information with whatever
header file information we already have. Otherwise, we might forget
something we already knew (e.g., that the header was #import'd already).
As per discussion with Doug Gregor on the IRC channel, introduce a new compiler switch: -fms-compatility.
Microsoft specific tweaking will now fall into 2 categories:
- fms-extension: Microsoft specific extensions that should never change the meaning of an otherwise well formed code. Currently map to LangOptions::Microsoft. (To be clearer, I am planning to change the name to LangOptions::MicrosoftExt).
- fms-compatibility: Really a MSVC emulation mode. Map to LangOptions::MicrosoftMode. Can change the meaning of an otherwise standard conformant program.
Douglas Gregor [Sat, 17 Sep 2011 00:05:03 +0000 (00:05 +0000)]
With modules, we can end up loading a new module after we've seen an
arbitrary amount of code. This forces us to stage the AST writer more
strictly, ensuring that we don't assign a declaration ID to a
declaration until after we're certain that no more modules will get
loaded.
In Microsoft mode, warn if an indirect goto jump over a variable initialization.
Also add a test case for the non Microsoft case because such test didn't exist.
Fix massive LiveVariables regression (due to LiveVariables rewrite) by addressing two performance problems:
- Speed of "merge()", which merged data flow facts. This was doing a set canonicalization on every insertion, which was super slow.
To fix this, we use ImmutableSetRef.
- Visit CFGBlocks in reverse postorder. This is a huge speedup, as on some test cases the algorithm would take many iterations
to converge.
This contains a bunch of copy-paste from UninitializedValues.cpp and ThreadSafety.cpp. The idea
was to get something working first, and then refactor the common logic for all three files into
a separate analysis/library entry point.
Anna Zaks [Fri, 16 Sep 2011 19:18:30 +0000 (19:18 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 5 of ?):
- Get rid of PathDiagnosticLocation(SourceRange r,..) constructor by providing a bunch of create methods.
- The PathDiagnosticLocation(SourceLocation L,..), which is used by crate methods, will eventually become private.
- Test difference is in the case when the report starts at the beginning of the function. We used to represent that point as a range of the very first token in the first statement. Now, it's just a single location representing the first character of the first statement.
Eli Friedman [Thu, 15 Sep 2011 23:15:27 +0000 (23:15 +0000)]
Tweak *mmintrin.h so that they don't make any bad assumptions about alignment (which probably has little effect in practice, but better to get it right). Make the load in _mm_loadh_pi and _mm_loadl_pi a single LLVM IR instruction to make optimizing easier for CodeGen.
Douglas Gregor [Thu, 15 Sep 2011 22:00:41 +0000 (22:00 +0000)]
Add an experimental flag -fauto-module-import that automatically turns
#include or #import direcctives of framework headers into module
imports of the corresponding framework module.
Anna Zaks [Thu, 15 Sep 2011 20:06:34 +0000 (20:06 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 4 of ?):
- The closing brace is always a single location, not a range.
- The test case previously had a location key 57:1 followed by a range [57:1 - 57:1].
Douglas Gregor [Thu, 15 Sep 2011 19:48:59 +0000 (19:48 +0000)]
Eliminate the list of modules from the preprocessor options. This was
used back when we had an -import-module command-line option, but it's
no longer used (or useful).
Anna Zaks [Thu, 15 Sep 2011 18:56:07 +0000 (18:56 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 2 of ?):
- Fix a fixme and move the logic of creating a PathDiagnosticLocation corresponding to a ProgramPoint into a PathDiagnosticLocation constructor.
- Rename PathDiagnosticLocation::create to differentiate from the added constructor.
Douglas Gregor [Thu, 15 Sep 2011 18:47:32 +0000 (18:47 +0000)]
When we load the first module, make sure that we wire up the ASTConsumer to the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in
[PCH] Overhaul how preprocessed entities are [de]serialized.
-Use an array of offsets for all preprocessed entities
-Get rid of the separate array of offsets for just macro definitions;
for references to macro definitions use an index inside the preprocessed
entities array.
-Deserialize each preprocessed entity lazily, at first request; not in bulk.
Paves the way for binary searching of preprocessed entities that will offer
efficiency and will simplify things on the libclang side a lot.
John McCall [Thu, 15 Sep 2011 06:49:18 +0000 (06:49 +0000)]
Rewrite this loop to use partial destruction; I'm not sure it's
possible for that to matter right now, but eventually I think we'll
need to unify this better, and then it might. Also, use a more
efficient looping structure.
Anna Zaks [Thu, 15 Sep 2011 01:08:34 +0000 (01:08 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 2 of ?):
- Modify all PathDiagnosticLocation constructors that take Stmt to also requre LocationContext.
- Add a constructor which should be used in case there is no valid statement/location (it will grab the location of the enclosing function).