Commit Graph

32573 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 7f44836998 Introduce local_begin()/local_end() methods in PreprocessingRecord which
return iterators for local, non-loaded, preprocessed entities.

llvm-svn: 140062
2011-09-19 20:40:42 +00:00
Argyrios Kyrtzidis 27bf76d6d2 In CodeGenAction::ExecuteAction() use SourceManager::translateFileLineCol()
instead of getLocation() since we don't care about expanded macro arguments.

llvm-svn: 140061
2011-09-19 20:40:38 +00:00
Argyrios Kyrtzidis 7c06d8666b [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.

llvm-svn: 140060
2011-09-19 20:40:35 +00:00
Argyrios Kyrtzidis 532c5196b0 Break SourceManager::translateFileLineCol into translateLineCol that returns the
source location of line:col of a specific FileID.

llvm-svn: 140059
2011-09-19 20:40:29 +00:00
Argyrios Kyrtzidis 64f6381097 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.

llvm-svn: 140058
2011-09-19 20:40:25 +00:00
Argyrios Kyrtzidis e6e67deeed Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
It already works (and is useful with) macro locs as well.

llvm-svn: 140057
2011-09-19 20:40:19 +00:00
Argyrios Kyrtzidis c284238aa2 Make ASTReader/ASTWriter friends of SourceLocation. They already
depend on internal knowledge of SourceLocation.

llvm-svn: 140056
2011-09-19 20:40:08 +00:00
Argyrios Kyrtzidis 9671ea9387 Introduce isLoadedSourceLocation() and isLocalSourceLocation() methods in SourceManager.
llvm-svn: 140055
2011-09-19 20:40:05 +00:00
Argyrios Kyrtzidis d67164e3cd Const-ify some methods in ASTReader.
llvm-svn: 140054
2011-09-19 20:40:02 +00:00
Argyrios Kyrtzidis b4199b659b For SourceManager::isBeforeInTranslationUnit, a location pointing
inside a macro argument should be regarded as coming before
the location of the expanded tokens.

llvm-svn: 140053
2011-09-19 20:39:57 +00:00
Argyrios Kyrtzidis b527a7cbf8 [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.

llvm-svn: 140052
2011-09-19 20:39:54 +00:00
Argyrios Kyrtzidis 8b7c08b897 For SourceManager::isBeforeInTranslationUnit, when one location
points at the inclusion/expansion point of the other, regard this
as coming before the other.

llvm-svn: 140051
2011-09-19 20:39:51 +00:00
Bill Wendling f0724e8e06 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.

llvm-svn: 140049
2011-09-19 20:31:14 +00:00
Richard Trieu 01fc001062 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.

llvm-svn: 140039
2011-09-19 19:01:00 +00:00
Devang Patel 5a54065c4f Tighten check to match an ivar with corresponding property by using ObjCImplementationDecl.
Radar 10139522 - Part 1.

llvm-svn: 140038
2011-09-19 18:54:16 +00:00
Matt Beaumont-Gay dcaacaa190 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.

llvm-svn: 140036
2011-09-19 18:51:20 +00:00
Fariborz Jahanian e20c0a5a66 objc - some refactoring of my last 'self' patch.
llvm-svn: 140031
2011-09-19 18:06:07 +00:00
John McCall 28a5b326e1 In apple-kext mode, use external linkage for explicit template instantiations
instead of internal linkage.

llvm-svn: 140030
2011-09-19 18:05:26 +00:00
Fariborz Jahanian a195a5182c CurContext cannot be null ever.
llvm-svn: 140022
2011-09-19 16:32:32 +00:00
Erik Verbruggen 631dfc6229 Removed an unused field and its accessors methods.
llvm-svn: 140017
2011-09-19 15:10:40 +00:00
Erik Verbruggen 852725b615 First test commit.
llvm-svn: 140016
2011-09-19 15:03:11 +00:00
Richard Smith c94ec84a3d In constructors, don't generate implicit initializers for members of anonymous structs contained within anonymous unions.
llvm-svn: 140015
2011-09-19 13:34:43 +00:00
Richard Smith b83e3eb37d Remove function which is unused as of r139996. Thanks to David Blaikie for bringing this to my attention.
llvm-svn: 140013
2011-09-19 11:19:27 +00:00
Francois Pichet 26e809692a Do not use builtin includes if -fms-compatibility is specified. Some MSVC header files have the same name as clang's builtins, this creates clash.
llvm-svn: 140009
2011-09-19 05:15:54 +00:00
Francois Pichet 39cba5343d Move the "jump bypasses variable initialization" error -> warning downgrade from -fms-extensions to -fms-compatibility.
llvm-svn: 140008
2011-09-18 21:48:27 +00:00
Francois Pichet 08d2fa0a78 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.

llvm-svn: 140007
2011-09-18 21:37:37 +00:00
Richard Smith 20104048be 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.

llvm-svn: 139997
2011-09-18 12:11:43 +00:00
Richard Smith 12d5ed8850 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.

llvm-svn: 139996
2011-09-18 11:14:50 +00:00
Richard Smith 4037235429 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.
llvm-svn: 139991
2011-09-18 00:06:34 +00:00
Nico Weber 7c29980d20 Let -Warray-bounds handle casted array types without false positives.
Fixes PR10771.

llvm-svn: 139990
2011-09-17 22:59:41 +00:00
Fariborz Jahanian db8015c449 objc - Treat type of 'self' in class methods as root of
class of this method. // rdar://10109725

llvm-svn: 139989
2011-09-17 19:23:40 +00:00
Fariborz Jahanian 8b148bb5b7 objc: Don't crash with decl context for property impl.
is missing. // rdar//10127639

llvm-svn: 139988
2011-09-17 18:48:50 +00:00
Francois Pichet 0706d203cf 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.

llvm-svn: 139987
2011-09-17 17:15:52 +00:00
Douglas Gregor 5d1bee253c 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).

llvm-svn: 139979
2011-09-17 05:35:18 +00:00
Francois Pichet 1b4f1637fb 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.

llvm-svn: 139978
2011-09-17 04:32:15 +00:00
Douglas Gregor c6b316acd9 Pass -fmodule-cache-path along to -cc1 properly
llvm-svn: 139977
2011-09-17 02:20:28 +00:00
Douglas Gregor 2fd3d401f9 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.

llvm-svn: 139974
2011-09-17 00:05:03 +00:00
Francois Pichet 2f55019bf0 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.

llvm-svn: 139971
2011-09-16 23:15:32 +00:00
Ted Kremenek 459597a6eb 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.

llvm-svn: 139968
2011-09-16 23:01:39 +00:00
Eli Friedman 0ee0b9fdaf Fix search paths for Ubuntu 11.04 x86. Patch by Stepan Dyatkovskiy.
llvm-svn: 139941
2011-09-16 21:04:38 +00:00
Anna Zaks efd182d992 [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.

llvm-svn: 139932
2011-09-16 19:18:30 +00:00
NAKAMURA Takumi 3f62af76b9 test/CodeGen/sse-builtins.c: Make this host-independent to unbreak posix-unlike hosts.
Without -ffreestanding, clang tries to seek /usr/include/stdlib.h in host filesystem, even on Windows hosts.

llvm-svn: 139899
2011-09-16 03:55:36 +00:00
Richard Trieu f8916e118a Moves calls of checkArithmeticNull() from CreateBuiltinBinOp() into the individual Check*Operands() functions.
llvm-svn: 139895
2011-09-16 00:53:10 +00:00
Caitlin Sadowski 086fb95da5 Thread safety: Adding FIXMEs and a couple cleanups
llvm-svn: 139894
2011-09-16 00:35:54 +00:00
Douglas Gregor 88b4ddfa91 Tweak the module auto-import heuristics a bit
llvm-svn: 139887
2011-09-16 00:22:46 +00:00
Richard Trieu 7a5c27276e Remove no longer needed LHSType and RHSType from checkArithmeticNull()
llvm-svn: 139879
2011-09-15 23:57:21 +00:00
Richard Trieu a25995dbb4 Change checkArithmeticNull() to use a NonNullType, instead of checking both the
LHSType and RHSType for everything.

llvm-svn: 139878
2011-09-15 23:51:29 +00:00
Eli Friedman 0d3d70a074 Remove standard library includes from test; they explode on Windows.
llvm-svn: 139875
2011-09-15 23:24:35 +00:00
Eli Friedman 9bb51adcce 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.
rdar://10054986

llvm-svn: 139874
2011-09-15 23:15:27 +00:00
Douglas Gregor 97eec24b0b 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.

llvm-svn: 139860
2011-09-15 22:00:41 +00:00