Commit Graph

13923 Commits

Author SHA1 Message Date
Rafael Espindola cd7720a03f Don't walk a linked list twice in the same function. On my machine this takes
"clang -cc1" on a file with 10k repetitions of
extern int no_such_variable;
from 1.434s to 1.133s.

llvm-svn: 168394
2012-11-20 23:23:57 +00:00
Richard Smith 1ab34b3ad5 PR14381: Never skip constexpr function bodies when code-completing. We may need
them in order to parse the rest of the file.

llvm-svn: 168327
2012-11-19 21:13:18 +00:00
Chandler Carruth 76a943be7b Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
   have been fixed in trunk GCC, and this fixes Clang as well. Notably,
   the logic was always intended to be last-match-wins like any other
   flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
   It also allowed the use of this flag on non-Darwin platforms where it
   has no actual meaning. Now this option is handled directly based on
   tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
   of dynamic-no-pic leaking through them. They also had the
   implementation details of the LLVM relocation model flag names
   leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
   many cases. For example, Darwin *always* uses PIC level 2 if it uses
   in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
   the flags specified, including -fPIE. Darwin never compiles in PIE
   mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
   a supported mode at all and may have caused some fallout in builds
   with complex PIC and PIE interactions.

The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.

Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.

llvm-svn: 168297
2012-11-19 03:52:03 +00:00
Chandler Carruth d6f93cbe7c Remove a no-op 'const' from a by-value return type.
llvm-svn: 168296
2012-11-19 03:52:00 +00:00
NAKAMURA Takumi c59776d1fe RecursiveASTVisitor.h: Rework Doug's r160404, "Eliminating the GCC_CAST hack, take two."
With this, ARCMT tests would not crash on certain hosts with g++ -O2, eg. cygwin g++-4.5.3.

r160404 crashed mingw32-g++-4.4.0. I guess method's pointer in conditional expression could not be handled.

llvm-svn: 168295
2012-11-19 00:51:37 +00:00
Dmitri Gribenko 76b91c3431 Documentation parsing: propely handle a lone '\endverbatim' and emit a warning.
We actually used to assert on this.

Thanks to NAKAMURA Takumi for noticing this!

llvm-svn: 168277
2012-11-18 00:30:31 +00:00
Dmitri Gribenko a01d4cfff2 Fix Doxygen comment start sequence.
llvm-svn: 168276
2012-11-17 23:53:22 +00:00
Andy Gibbs a8df57a962 Made the "expected string literal" diagnostic more expressive
llvm-svn: 168267
2012-11-17 19:16:52 +00:00
Andy Gibbs 58905d251b Refactored duplicate string literal lexing code within Preprocessor, into a
common LexStringLiteral function.  In doing so, some consistency problems have
been ironed out (e.g. where the first token in the string literal was lexed
with macro expansion, but subsequent ones were not) and also an erroneous
diagnostic has been corrected.

LexStringLiteral is complemented by a FinishLexStringLiteral function which
can be used in the situation where the first token of the string literal has
already been lexed.

llvm-svn: 168266
2012-11-17 19:15:38 +00:00
Benjamin Kramer dca1ff8909 Remove copy ctor that provides no value over the default.
It's also simpler to just copy the words than mangling bits like this ctor did.

llvm-svn: 168258
2012-11-17 09:14:31 +00:00
Chad Rosier 1ccfff111d Typo.
llvm-svn: 168222
2012-11-16 23:41:41 +00:00
Dmitri Gribenko dddfc51397 StmtDumper: remove incomplete support for limiting the maximum dump depth.
There are better ways of limiting the amount of information if there is a need
for that.

Patch by Philip Craig.

llvm-svn: 168206
2012-11-16 21:43:31 +00:00
Nick Lewycky cc8990f629 Store this Decl* as a Decl* instead of a uintptr_t. No functionality change.
llvm-svn: 168145
2012-11-16 08:40:59 +00:00
Douglas Gregor f8715de599 Since CreateTargetInfo is taking ownership of the target options, pass
it as a pointer. 

llvm-svn: 168136
2012-11-16 04:24:59 +00:00
Douglas Gregor 106d7a2704 Remove unused diagnostics
llvm-svn: 168135
2012-11-16 04:10:20 +00:00
Richard Smith 1648847248 A step towards sorting out handling of triviality of special members in C++11.
Separate out the notions of 'has a trivial special member' and 'has a
non-trivial special member', and use them appropriately. These are not
opposites of one another (there might be no special member, or in C++11 there
might be a trivial one and a non-trivial one). The CXXRecordDecl predicates
continue to produce incorrect results, but do so in fewer cases now, and
they document the cases where they might be wrong.

No functionality changes are intended here (they will come when the predicates
start producing the right answers...).

llvm-svn: 168119
2012-11-16 00:53:38 +00:00
Jordan Rose b5b0fc196e [analyzer] Mark symbol values as dead in the environment.
This allows us to properly remove dead bindings at the end of the top-level
stack frame, using the ReturnStmt, if there is one, to keep the return value
live. This in turn removes the need for a check::EndPath callback in leak
checkers.

This does cause some changes in the path notes for leak checkers. Previously,
a leak would be reported at the location of the closing brace in a function.
Now, it gets reported at the last statement. This matches the way leaks are
currently reported for inlined functions, but is less than ideal for both.

llvm-svn: 168066
2012-11-15 19:11:27 +00:00
Fariborz Jahanian 0e3043b2ed block extended signatur option. Change previous option
to a cc1 -fencode-extended-block-signature and pass it
to cc1 and recognize this option to produce extended block
type signature. // rdar://12109031 

llvm-svn: 168063
2012-11-15 19:02:45 +00:00
Argyrios Kyrtzidis 5259524b2f [modules] Use a memory buffer directly as input for the module includes,
instead of messing with virtual files.

llvm-svn: 168062
2012-11-15 18:57:27 +00:00
Argyrios Kyrtzidis 2ec2936778 [modules] Setup the import location of a module file and use it
as the include location of the main file of an imported module.

llvm-svn: 168061
2012-11-15 18:57:22 +00:00
Dmitri Gribenko 707cb04a9f Remove unused diagnostics from TableGen files.
llvm-svn: 168055
2012-11-15 18:32:56 +00:00
Dmitri Gribenko b2aa9234b6 Use empty parens for empty function parameter list instead of '(void)'.
llvm-svn: 168041
2012-11-15 14:28:07 +00:00
Lang Hames 65992f454c Make -ffp-contract a codegen option, rather than a laguage option. This makes
more sense anyway - it determines how expressions are codegen'd. It also ensures
that -ffp-contract=fast has the intended effect when compiling LLVM IR.

llvm-svn: 168027
2012-11-15 07:51:26 +00:00
Nick Lewycky 5cc9ebb723 Revert r167567, restoring the ability of clang to run gcc in cases where it
can't handle the input file type. This resulted in PR14338.

llvm-svn: 168024
2012-11-15 05:36:36 +00:00
Jordan Rose 2d98b97e10 [analyzer] Make sure calls in synthesized functions have valid path locations.
We do this by using the "most recent" good location: if a synthesized
function 'A' calls another function 'B', the path notes for the call to 'B'
will be placed at the same location as the path note for calling 'A'.

Similarly, the call to 'A' will have a note saying "Entered call from...",
and now we just don't emit that (since the user doesn't have a body to look
at anyway).

Previously, we were doing this for the "Calling..." notes, but not for the
"Entered call from..." or "Returning to caller". This caused a crash when
the path entered and then exiting a call within a synthesized body.

<rdar://problem/12657843>

llvm-svn: 168019
2012-11-15 02:07:23 +00:00
Fariborz Jahanian a4ca19694e objective-C blocks: make cc1 flag -encode-extended-block-signature
the default. // rdar://12109031

llvm-svn: 168007
2012-11-15 00:01:28 +00:00
Richard Smith 0b50cb79ad Add -cc1 option -fno-diagnostics-use-presumed-location, a handy mode for
working with preprocessed testcases. This causes source locations in
diagnostics to point at the spelling location instead of the presumed location,
while still keeping the semantic effects of the line directives (entering and
leaving system-header mode, primarily).

llvm-svn: 168004
2012-11-14 23:55:25 +00:00
Fariborz Jahanian 64223e6db1 objective-C blocks: under cc1 flag -encode-extended-block-signature,
generate expanded signature encoding to include types as we
already do this for protocol method lists.
// rdar://12109031

llvm-svn: 167997
2012-11-14 23:11:38 +00:00
Argyrios Kyrtzidis 922b7a186b In ExpressionEvaluationContextRecord manage LambdaMangle with a shared
pointer, otherwise we will double free it when ExpressionEvaluationContextRecord
gets copied.

Fixes crash in rdar://12645424 & http://llvm.org/PR14252

llvm-svn: 167946
2012-11-14 19:16:13 +00:00
Fariborz Jahanian a9d4464baf objective-C blocks: Provide layout map for byref
variables captured in a block. // rdar://12184410

llvm-svn: 167931
2012-11-14 17:15:51 +00:00
Benjamin Kramer d81108f0bc s/tranform/transform/
llvm-svn: 167929
2012-11-14 15:08:31 +00:00
Eli Friedman 14d3c79b45 Suppress elided variadic macro argument extension diagnostic for macros using
the related comma pasting extension.

In certain cases, we used to get two diagnostics for what is essentially one
extension.  This change suppresses the first diagnostic in certain cases
where we know we're going to print the second diagnostic.  The
diagnostic is redundant, and it can't be suppressed in the definition
of the macro because it points at the use of the macro, so we want to
avoid printing it if possible.

The implementation works by detecting constructs which look like comma
pasting at the time of the definition of the macro; this information
is then used when the macro is used.  (We can't actually detect
whether we're using the comma pasting extension until the macro is
actually used, but we can detecting constructs which will be comma
pasting if the varargs argument is elided.)

<rdar://problem/12292192>

llvm-svn: 167907
2012-11-14 02:18:46 +00:00
David Blaikie 095deba533 Provide the correct mangling and linkage for certain unnamed nested classes.
This corrects the mangling and linkage of classes (& their member functions) in
cases like this:

  struct foo {
    struct {
      void func() { ... }
    } x;
  };

we were accidentally giving this nested unnamed struct 'no' linkage where it
should've had the linkage of the outer class. The mangling was incorrecty too,
mangling as TU-wide unnamed type mangling of $_X rather than class-scoped
mangling of UtX_.

This also fixes -Wunused-member-function which would incorrectly diagnose
'func' as unused due to it having no linkage & thus appearing to be TU-local
when in fact it might be correctly used in another TU.

Similar mangling should be applied to function local classes in similar cases
but I've deferred that for a subsequent patch.

Review/discussion by Richard Smith, John McCall, & especially Eli Friedman.

llvm-svn: 167906
2012-11-14 01:52:05 +00:00
Anders Carlsson 0f6771305b Use consistent spelling of 'behavior' in a C++ warning.
llvm-svn: 167902
2012-11-14 01:39:09 +00:00
Nick Lewycky 4a4d8f2f3b This function isn't called SaveFiles any more.
llvm-svn: 167901
2012-11-14 01:33:49 +00:00
Richard Smith 41ae3288fd Remove another questionable use of hasTrivial*. The relevant thing for this
test was whether the /selected/ operator= was trivial, not whether the class
had any trivial (or any non-trivial) operator=s.

llvm-svn: 167897
2012-11-14 00:50:40 +00:00
John McCall ea0a39e7ad Accept and pass arguments to __unknown_anytype in argument
positions of Objective-C methods.

It is possible to recover a lot of type information about
Objective-C methods from the reflective metadata for their
implementations.  This information is not rich when it
comes to struct types, however, and it is not possible to
produce a type in the debugger's round-tripped AST which
will really do anything useful during type-checking.
Therefore we allow __unknown_anytype in these positions,
which essentially disables type-checking for that argument.
We infer the parameter type to be the unqualified type of
the argument expression unless that expression is an
explicit cast, in which case it becomes the type-as-written
of that cast.

rdar://problem/12565338

llvm-svn: 167896
2012-11-14 00:49:39 +00:00
Matt Beaumont-Gay d7a527c438 Fix typo
llvm-svn: 167891
2012-11-14 00:00:25 +00:00
Daniel Dunbar cf3f2c49ea Revert r167801, "[preprocessor] When #including something that contributes no
tokens at all,". This change broke External/Nurbs in LLVM test-suite.

llvm-svn: 167858
2012-11-13 19:12:37 +00:00
David Blaikie 3403feb1d0 Simplify function try/catch scope handling.
Based on post-commit review feedback for r167766 by Richard Smith.

llvm-svn: 167856
2012-11-13 18:51:45 +00:00
Argyrios Kyrtzidis 4f10a3e9f0 [preprocessor] When #including something that contributes no tokens at all,
don't recursively continue lexing.

This avoids a stack overflow with a sequence of many empty #includes.
rdar://11988695

llvm-svn: 167801
2012-11-13 01:03:15 +00:00
Kaelyn Uhrain 3d699e02ae A couple of small fixes to r167783
llvm-svn: 167791
2012-11-13 00:18:47 +00:00
Kaelyn Uhrain 8681f9d46d Enable C++11 attribute syntax for warn_unused_result and allow it to be
applied to CXXRecordDecls, where functions with that return type will
inherit the warn_unused_result attribute.

Also includes a tiny fix (with no discernable behavior change for
existing code) to re-sync AttributeDeclKind enum and
err_attribute_wrong_decl_type with warn_attribute_wrong_decl_type since
the enum is used with both diagnostic messages to chose the correct
description.

llvm-svn: 167783
2012-11-12 23:48:05 +00:00
David Blaikie 1d6178065c Fix more try scoping bugs introduced by r167650.
Introduces more clear scoping flags & flag combinations which should hopefully
be more understandable.

llvm-svn: 167766
2012-11-12 22:25:41 +00:00
Bill Wendling 887b485dbe Check that the input size is correct for the given constraint.
The 'a', 'c', and 'd' constraints on i386 mean a 32-bit register. We cannot
place a 64-bit value into the 32-bit register. Error out instead of causing the
compiler to spew general badness.
<rdar://problem/12415959>

llvm-svn: 167717
2012-11-12 06:42:51 +00:00
Justin Holewinski 2700433f89 [NVPTX] Fix const modifier on builtins
Some NVVM intrinsics were incorrectly labeled.

llvm-svn: 167700
2012-11-12 03:16:56 +00:00
Daniel Jasper 33806cdefc Fix binding of nodes in case of forEach..() matchers.
When recursively visiting the generated matches, the aggregated bindings need
to be copied during the recursion. Otherwise, we they might not be properly
overwritten (which is shown by the test), or there might be bound nodes present
that were bound on a different matching branch.

Review: http://llvm-reviews.chandlerc.com/D112
llvm-svn: 167695
2012-11-11 22:14:55 +00:00
Nico Weber 07351f8e78 Remove unneeded includes from IdentifierTable
llvm-svn: 167694
2012-11-11 21:39:39 +00:00
Nico Weber 496b6dd5b1 Delete comment reference to non-existent method
llvm-svn: 167692
2012-11-11 21:02:03 +00:00
Nico Weber 158a31abe2 s/BCPLComment/LineComment/
llvm-svn: 167690
2012-11-11 07:02:14 +00:00
Richard Smith 67ea635f7a Fix a typo which Matt pointed out.
llvm-svn: 167679
2012-11-11 00:28:33 +00:00
Douglas Gregor dc97457178 Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.

llvm-svn: 167668
2012-11-10 07:24:09 +00:00
Michael Liao 625a875f05 Add clang support of RTM from TSX
- New options '-mrtm'/'-mno-rtm' are added to enable/disable RTM feature
- Builtin macro '__RTM__' is defined if RTM feature is enabled
- RTM intrinsic header is added and introduces 3 new intrinsics, namely
  '_xbegin', '_xend', and '_xabort'.
- 3 new builtins are added to keep compatible with gcc, namely
  '__builtin_ia32_xbegin', '__builtin_ia32_xend', and '__builtin_ia32_xabort'.
- Test cases for pre-defined macro and new intrinsic codegen are added.

llvm-svn: 167665
2012-11-10 05:17:46 +00:00
Richard Smith 9fbda3953b -momit-leaf-frame-pointer is a -m option, not a -f option.
llvm-svn: 167664
2012-11-10 04:54:44 +00:00
Douglas Gregor 6200470112 Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>

llvm-svn: 167651
2012-11-10 01:18:17 +00:00
David Blaikie 1c9c90495d PR14296: function parameter name collisions in function try/catch
C++11 3.3.3/2 "A parameter name shall not be redeclared in the outermost block
of the function definition nor in the outermost block of any handler associated
with a function-try-block."

It's not totally clear to me whether the "FIXME" case is covered by this, but
Richard Smith thinks it probably should be. It's just a bit more involved to
fix that case.

llvm-svn: 167650
2012-11-10 01:04:23 +00:00
Justin Holewinski c0cad046b6 [NVPTX] Add __nvvm_* intrinsics as Clang builtins
Fixes bug 13354.

llvm-svn: 167647
2012-11-09 23:50:51 +00:00
Richard Smith e0ae5356fc Document -W in clang --help. Also make the help text more consistent (don't end descriptions in periods, use | to separate possible values).
llvm-svn: 167645
2012-11-09 23:30:30 +00:00
Richard Smith 18915c4eac Don't include the help for -mips* in clang --help. These are just aliases for other options, and not common enough to be worth including here.
llvm-svn: 167644
2012-11-09 23:26:04 +00:00
Richard Smith 4c487827bf -Wlarge-by-value-copy may be awesome, but it really shouldn't be the one and
only -W flag which clang --help lists.

llvm-svn: 167643
2012-11-09 23:18:31 +00:00
Richard Smith b6075f4abd Remove --help text for deprecated sanitizer options, add --help text for -fsanitize=.
llvm-svn: 167639
2012-11-09 22:50:51 +00:00
Richard Smith e70ed8690f PR14303: Add a NoDriverOption flag to those options which are not accepted by
the driver (the options defined in CC1Options.td) and exclude their help from
"clang --help".

llvm-svn: 167638
2012-11-09 22:36:44 +00:00
Chad Rosier c1c3924e14 Add string to try and fix build from r167629.
llvm-svn: 167631
2012-11-09 20:00:52 +00:00
Argyrios Kyrtzidis dc6bb4982f Add a SourceLocation::printToString() that returns in a std::string what dump()
writes to stderr; for debugging purposes.

llvm-svn: 167629
2012-11-09 19:40:48 +00:00
Argyrios Kyrtzidis 6566e23e13 Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer
for completeness and use it in CompilerInstance::InitializeSourceManager if
the input is a memory buffer.

llvm-svn: 167628
2012-11-09 19:40:45 +00:00
Argyrios Kyrtzidis 873c8583e0 Turn FrontendInputFile into an immutable class and have it also accept
a memory buffer instead of only a filename.

llvm-svn: 167627
2012-11-09 19:40:39 +00:00
Argyrios Kyrtzidis 1b3240b0aa Make CompilerInstance::InitializeSourceManager accept a FrontendInputFile,
no functionality change.

llvm-svn: 167626
2012-11-09 19:40:33 +00:00
Rafael Espindola c93b074bda Don't use so many bits.
llvm-svn: 167624
2012-11-09 19:03:35 +00:00
Chad Rosier d87e4f7ad8 Implement -mstrict-align using '-backend-option -arm-strict-align' as this saves
us from having to make any backend changes.

llvm-svn: 167623
2012-11-09 18:27:01 +00:00
Chad Rosier 6002702b06 [driver] Add a -mstrict-align compiler option for ARM targets.
rdar://12340498

llvm-svn: 167619
2012-11-09 17:29:19 +00:00
Abramo Bagnara 8d16bd4d10 Allow to pass from syntactic form of InitListExpr to semantic form (just as viceversa). No functionality change.
llvm-svn: 167591
2012-11-08 18:41:43 +00:00
Daniel Dunbar c3bd9f5c50 Driver/Darwin: The -arch argument values aren't exactly the arch names from a
triple.

 - Translate the special case of powerpc to its expected -arch name.

llvm-svn: 167571
2012-11-08 03:38:26 +00:00
Bob Wilson 0c79f3cf3e Rip out a bunch of code for invoking gcc from clang.
llvm-svn: 167567
2012-11-08 01:03:34 +00:00
Bob Wilson d0de8ceb57 Remove code to fall back to llvm-gcc for i386 kexts.
More cleanups to follow in separate commits....

llvm-svn: 167566
2012-11-08 01:03:29 +00:00
Douglas Gregor 188dbef26d When loading a module fails because it is out of date, rebuild that
module in place. <rdar://problem/10138913>

llvm-svn: 167539
2012-11-07 17:46:15 +00:00
Jordan Rose a1046ece32 [analyzer] Add some examples for the common REGISTER_*_WITH_PROGRAMSTATEs.
No functionality change (doc comments only).

llvm-svn: 167523
2012-11-07 02:35:33 +00:00
Ted Kremenek 514fc6fa0f Add -Wmismatched-return-types flag for existing warning on conflicting return types.
llvm-svn: 167518
2012-11-07 01:43:44 +00:00
Ted Kremenek c6d8efd041 Add -Wmismatched-parameter-types flag for existing warning on conflicting parameter types.
llvm-svn: 167515
2012-11-07 01:25:56 +00:00
David Blaikie 7b97aef997 PR13552: Fix the end location of a CXXNewExpr.
Spent longer than reasonable looking for a nice way to test this & decided to
give up for now. Open to suggestions/requests. Richard Smith suggested adding
something to ASTMatchers but it wasn't readily apparent how to test this with
that.

llvm-svn: 167507
2012-11-07 00:12:38 +00:00
Douglas Gregor 5290182856 Tease out the routine that reads the control block of an AST file from
the validation of an AST file against a specific set of options.

llvm-svn: 167504
2012-11-06 23:40:54 +00:00
Argyrios Kyrtzidis 1c4db8d18c [libclang] Add some comments about the version constants for the libclang API.
llvm-svn: 167489
2012-11-06 21:21:49 +00:00
Douglas Gregor 9194a91dc9 Introduce inferred framework modules into the module map file,
allowing a module map to be placed one level above the '.framework'
directories to specify that all .frameworks within that directory can
be inferred as framework modules. One can also specifically exclude
frameworks known not to work.

This makes explicit (and more restricted) behavior modules have had
"forever", where *any* .framework was assumed to be able to be built
as a module. That's not necessarily true, so we white-list directories
(with exclusions) when those directories have been audited.

llvm-svn: 167482
2012-11-06 19:39:40 +00:00
Michael Han 64536a6d25 Teach Clang parser to reject C++11 attributes that appertain to declaration specifiers.
We don't support any C++11 attributes that appertain to declaration specifiers so reject 
the attributes in parser until we support them; this also conforms to what g++ 4.8 is doing.

llvm-svn: 167481
2012-11-06 19:34:54 +00:00
Nico Weber 00420eddc3 Delete an outdated comment.
llvm-svn: 167441
2012-11-06 05:20:23 +00:00
Anna Zaks 49bb65024c [analyzer] Remove isWithinInlined. It's been replaced with inTopFrame().
Thanks Jordan.

llvm-svn: 167438
2012-11-06 04:20:54 +00:00
Richard Smith aa71657749 Per discussion on cfe-commits, treat -faddress-sanitizer,
-fno-address-sanitizer, -fthread-sanitizer, -fno-thread-sanitizer, and
-fcatch-undefined-behavior as deprecated: produce a warning if they are used
pointing to the corresponding -fsanitize= option. In passing add the missing
'-' to some diagnostics.

llvm-svn: 167429
2012-11-06 01:12:02 +00:00
Daniel Dunbar e2951f48bf Frontend: Add support for reading named pipes as the main file.
- The whole {File,Source}Manager is built around wanting to pre-determine the
   size of files, so we can't fit this in naturally. Instead, we handle it like
   we do STDIN, where we just replace the main file contents upfront.

llvm-svn: 167419
2012-11-05 22:53:33 +00:00
Richard Smith b1b0ab41e7 Use the individual -fsanitize=<...> arguments to control which of the UBSan
checks to enable. Remove frontend support for -fcatch-undefined-behavior,
-faddress-sanitizer and -fthread-sanitizer now that they don't do anything.

llvm-svn: 167413
2012-11-05 22:21:05 +00:00
Richard Smith 52be619c84 Add -fsanitize=<sanitizers> argument to driver and frontend, and add
-fno-sanitize=<sanitizers> argument to driver. These allow ASan, TSan, and the
various UBSan checks to be enabled and disabled separately. Right now, the
different modes can't be combined, but the intention is that combining UBSan
and the other sanitizers will be permitted in the near future.

Currently, the UBSan checks will all be enabled if any of them is; that will be
fixed by the next patch.

llvm-svn: 167411
2012-11-05 22:04:41 +00:00
Richard Smith 43f9d9c6d9 Rename LangOptions members for address sanitizer and thread sanitizer from
*Sanitizer to Sanitize* in preparation for later patches.

llvm-svn: 167405
2012-11-05 21:48:12 +00:00
Jordan Rose 520a30fd05 [analyzer] Move convenience REGISTER_*_WITH_PROGRAMSTATE to CheckerContext.h
As Anna pointed out, ProgramStateTrait.h is a relatively obscure header,
and checker writers may not know to look there to add their own custom
state.

The base macro that specializes the template remains in ProgramStateTrait.h
(REGISTER_TRAIT_WITH_PROGRAMSTATE), which allows the analyzer core to keep
using it.

llvm-svn: 167385
2012-11-05 16:58:00 +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
Lang Hames 2954ceab82 Support interleaving of other pragmas with FP_CONTRACT at the beginning of a
compound statement.

llvm-svn: 167363
2012-11-03 22:29:05 +00:00
Dmitri Gribenko 941ab0fb6f Remove a const_cast by propagating constness to the member function.
llvm-svn: 167357
2012-11-03 14:24:57 +00:00
Anna Zaks 8d1f6ed9a8 [analyzer] Run remove dead on end of path.
This will simplify checkers that need to register for leaks. Currently,
they have to register for both: check dead and check end of path.

I've modified the SymbolReaper to consider everything on the stack dead
if the input StackLocationContext is 0.

(This is a bit disruptive, so I'd like to flash out all the issues
asap.)

llvm-svn: 167352
2012-11-03 02:54:20 +00:00
Anna Zaks 44dc91b4df [analyzer] add LocationContext::inTopFrame() helper.
llvm-svn: 167351
2012-11-03 02:54:16 +00:00
Anna Zaks 2510608e81 [analyzer] Refactor: Remove Pred from NodeBuilderContext.
Node builders should manage the nodes, not the context.

llvm-svn: 167350
2012-11-03 02:54:11 +00:00
Jordan Rose 829c383114 [analyzer] Add some convenience accessors to CallEvent, and use them.
These are CallEvent-equivalents of helpers already accessible in
CheckerContext, as part of making it easier for new checkers to be written
using CallEvent rather than raw CallExprs.

llvm-svn: 167338
2012-11-02 23:49:29 +00:00
Jordan Rose 0da6747901 [analyzer] isCLibraryFunction: check that the function is at TU-scope.
Also, Decls already carry a pointer to the ASTContext, so there's no need
to pass an extra argument to the predicate.

llvm-svn: 167337
2012-11-02 23:49:24 +00:00
DeLesley Hutchins 66e300e6f9 Thread safety analysis: Fixed ICE caused by double delete when late parsed
attributes are attached to function declarations nested inside a class method.

llvm-svn: 167321
2012-11-02 21:44:32 +00:00
Richard Trieu f19039c294 Fix grammar of diagnostic message.
llvm-svn: 167319
2012-11-02 21:33:17 +00:00
Ted Kremenek 42f704d67e Move -Wimplicit-retain-self to be off-by-default until we can evaluate
more how noisy it is.

llvm-svn: 167300
2012-11-02 17:48:49 +00:00
Eli Friedman ff421c97e1 Delete lines which do nothing from DiagnosticGroups.td.
llvm-svn: 167281
2012-11-02 03:35:13 +00:00
Eli Friedman 960755bafd Add missing diagnostic group to format string warning.
llvm-svn: 167279
2012-11-02 02:14:44 +00:00
Jordan Rose b9ed61f93d [analyzer] Convert some of the harder cases over to ProgramStateTrait macros.
Add FIXMEs for the traits visible from multiple translation units.
Currently the macros hide their key types in an anonymous namespace.

llvm-svn: 167277
2012-11-02 01:54:42 +00:00
Jordan Rose 0c153cb277 [analyzer] Use nice macros for the common ProgramStateTraits (map, set, list).
Also, move the REGISTER_*_WITH_PROGRAMSTATE macros to ProgramStateTrait.h.

This doesn't get rid of /all/ explicit uses of ProgramStatePartialTrait,
but it does get a lot of them.

llvm-svn: 167276
2012-11-02 01:54:06 +00:00
Jordan Rose e10d5a7659 [analyzer] Rename 'EmitReport' to 'emitReport'.
No functionality change.

llvm-svn: 167275
2012-11-02 01:53:40 +00:00
Eli Friedman 8f88f06dd2 Tweak wording and add diagnostic groups to misc diagnostics.
llvm-svn: 167274
2012-11-02 01:40:23 +00:00
Eli Friedman 0d0355abfc Change diagnostics for enums with fixed underlying type so in C++98 mode, we cite C++11.
llvm-svn: 167273
2012-11-02 01:34:28 +00:00
Manuel Klimek bd0e2b7111 Insert interception point onStartOfTranslationUnit.
Often users of the ASTMatchers want to add tasks that are done once per
translation unit, for example, cleaning up caches. Combined with the
interception point for the end of source file one can add to the factory
creation, this covers the cases we've seen users need.

llvm-svn: 167271
2012-11-02 01:31:03 +00:00
Richard Trieu 1f3ea7b6b5 When finding a '(' after '::', emit error with hint to remove '(' and matching
')', if found.  Don't crash.
Fixes PR11852.

llvm-svn: 167268
2012-11-02 01:08:58 +00:00
Quentin Colombet 4e172067b2 Update the front end to use minsize attribute
llvm-svn: 167266
2012-11-01 23:55:47 +00:00
Richard Smith bd55daf2ee Remove first argument from Arg::getValue; it's been unused since r105760.
llvm-svn: 167211
2012-11-01 04:30:05 +00:00
Richard Smith 33fd551258 Remove CompilerInvocation::toArgs and clang -cc1test mode. These were untested
and apparently unused (and since they are untested, they're presumably also
broken).

llvm-svn: 167210
2012-11-01 03:48:49 +00:00
Argyrios Kyrtzidis b26a24cca2 [libclang] Introduce clang_Cursor_getReceiverType which returns the CXType for
the receiver of an ObjC message expression.

rdar://12578643

llvm-svn: 167201
2012-11-01 02:01:34 +00:00
NAKAMURA Takumi 1e5eac6dfe clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h: Appease msvc.
llvm-svn: 167199
2012-11-01 01:47:02 +00:00
Jordan Rose a4a9b3691d [analyzer] Optimize assumeDual by assuming constraint managers are consistent.
Specifically, if adding a constraint makes the current system infeasible,
assume the constraint is false, instead of attempting to add its negation.

In +Asserts builds we will still assert that at least one state is feasible.

Patch by Ryan Govostes!

llvm-svn: 167195
2012-11-01 01:05:39 +00:00
Jordan Rose 14fe9f3631 [analyzer] Rename ConditionTruthVal::isTrue to isConstrainedTrue.
(and the same for isFalse)

No functionality change.

llvm-svn: 167186
2012-11-01 00:18:27 +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
Chad Rosier bd465a9cc7 [driver] Remove the -ccc-host-triple alias. This has been replaced by the
-target option.
rdar://10692880

llvm-svn: 167158
2012-10-31 18:59:38 +00:00
Chad Rosier 83f16bf445 [driver] Completely rework how superfluous options are stripped out of the crash
diagnostics script.

This addresses the FIXME pertaining to quoted arguments.  We also delineate
between those flags that have an argument (e.g., -D macro, -MF file) and
those that do not (e.g., -M, -MM, -MG).  Finally, we add the -dwarf-debug-flags
to the list of flags to be removed.
rdar://12329974

llvm-svn: 167152
2012-10-31 18:31:33 +00:00
Jordan Rose 417591fba7 [analyzer] Let ConstraintManager subclasses provide a more efficient checkNull.
Previously, every call to a ConstraintManager's isNull would do a full
assumeDual to test feasibility. Now, ConstraintManagers can override
checkNull if they have a cheaper way to do the same thing.
RangeConstraintManager can do this in less than half the work.

<rdar://problem/12608209>

llvm-svn: 167138
2012-10-31 16:44:55 +00:00
Rafael Espindola 69aa04dd8f Remove the -ccc-no-clang option.
llvm-svn: 167093
2012-10-31 01:21:20 +00:00
Anna Zaks 408f7d0144 Address Jordan's review: comments, spaces.
llvm-svn: 167091
2012-10-31 01:18:22 +00:00
Rafael Espindola 74c5fd93b9 Remove ccc-no-clang-cpp, which is also dead now.
llvm-svn: 167062
2012-10-30 23:49:11 +00:00
David Blaikie a0613170b4 Handle string encoding diagnostics when there are too many invalid ranges.
llvm-svn: 167059
2012-10-30 23:22:22 +00:00
Daniel Jasper 6fc3433b15 Implement descendant matchers for NestedNamespecifiers
This implements has(), hasDescendant(), forEach() and
forEachDescendant() for NestedNameSpecifier and NestedNameSpecifierLoc
matchers.

Review: http://llvm-reviews.chandlerc.com/D86
llvm-svn: 167017
2012-10-30 15:42:00 +00:00
Ted Kremenek 0a43c26acb Change -Wcompare-distinct-pointer-type to -Wcompare-distinct-pointer-types, as
the warning is about comparing different types (plural).

llvm-svn: 167003
2012-10-30 04:43:57 +00:00
Anna Zaks 302da83fc2 [analyzer] Fix a bug in REGISTER_MAP_WITH_PROGRAMSTATE
The ImmutableMap should not be the key into the GDM map as there could
be several entries with the same map type. Thanks, Jordan.

This complicates the usage of the macro a bit. When we want to retrieve
the whole map, we need to use another name. Currently, I set it to be
Name ## Ty as in "type of the map we are storing in the ProgramState".

llvm-svn: 167000
2012-10-30 04:17:40 +00:00
Anna Zaks 4afaaf228c [analyzer] Rename REGISTER_MAP_WITH_GDM ->REGISTER_MAP_WITH_PROGRAMSTATE
llvm-svn: 166999
2012-10-30 04:17:18 +00:00
Rafael Espindola 9141aa1b1e Remove leftover const.
llvm-svn: 166996
2012-10-30 01:49:46 +00:00
Rafael Espindola fd5e756ad0 getOriginalSourceFileName and getOriginalSourceFile can return a StringRef.
MaybeAddSystemRootToFilename doesn't need to return anything, it modifies
its argument.

llvm-svn: 166988
2012-10-30 00:38:13 +00:00
Rafael Espindola 84619411eb In the past "production" clang builds would not be used for c++, and
we had the -ccc-clang-cxx and -ccc-no-clang-cxx options to force them
on or off for testing.

Clang c++ support is now production quality and these options are dead.

llvm-svn: 166986
2012-10-30 00:13:16 +00:00
Argyrios Kyrtzidis f7cc29519a [libclang] Bump the version number of the libclang API.
llvm-svn: 166984
2012-10-29 23:53:52 +00:00
Rafael Espindola 077bc8bdaa Remove a bit of dead code.
llvm-svn: 166983
2012-10-29 23:41:43 +00:00
Rafael Espindola e878343c12 Move getOriginalSourceFileName inline. Patch by Laszlo Nagy.
llvm-svn: 166981
2012-10-29 23:26:40 +00:00
Argyrios Kyrtzidis 5b216ed713 [libclang] Introduce a version constant for the libclang API.
rdar://12587974

llvm-svn: 166980
2012-10-29 23:24:44 +00:00
Anna Zaks 2ab0321b0d [analyzer] Add checker helpers to CheckerContext.
- Adding Immutable Map to GDM and getIdentifierInfo helper method.

llvm-svn: 166975
2012-10-29 22:51:44 +00:00
Quentin Colombet ee3e0fb632 Revert commit r166946
llvm-svn: 166957
2012-10-29 18:28:57 +00:00
Quentin Colombet 0d6b5e5fde Make forcesizeopt attribute available to the end user
llvm-svn: 166946
2012-10-29 17:56:23 +00:00
Jordan Rose 25c0ea8995 -Warc-repeated-use-of-weak: allow single reads in loops from local variables.
Previously, the warning would erroneously fire on this:

for (Test *a in someArray)
  use(a.weakProp);

...because it looks like the same property is being accessed over and over.
However, clearly this is not the case. We now ignore loops like this for
local variables, but continue to warn if the base object is a parameter,
global variable, or instance variable, on the assumption that these are
not repeatedly usually assigned to within loops.

Additionally, do-while loops where the condition is 'false' are not really
loops at all; usually they're just used for semicolon-swallowing macros or
using "break" like "goto".

<rdar://problem/12578785&12578849>

llvm-svn: 166942
2012-10-29 17:46:47 +00:00
Jordan Rose ec44ac6a59 [analyzer] New option to not suppress null return paths if an argument is null.
Our one basic suppression heuristic is to assume that functions do not
usually return NULL. However, when one of the arguments is NULL it is
suddenly much more likely that NULL is a valid return value. In this case,
we don't suppress the report here, but we do attach /another/ visitor to
go find out if this NULL argument also comes from an inlined function's
error path.

This new behavior, controlled by the 'avoid-suppressing-null-argument-paths'
analyzer-config option, is turned off by default. Turning it on produced
two false positives and no new true positives when running over LLVM/Clang.

This is one of the possible refinements to our suppression heuristics.
<rdar://problem/12350829>

llvm-svn: 166941
2012-10-29 17:31:59 +00:00
Jordan Rose 199fdd825f [analyzer] Use the CallEnter node to get a value for tracked null arguments.
Additionally, don't collect PostStore nodes -- they are often used in
path diagnostics.

Previously, we tried to track null arguments in the same way as any other
null values, but in many cases the necessary nodes had already been
collected (a memory optimization in ExplodedGraph). Now, we fall back to
using the value of the argument at the time of the call, which may not
always match the actual contents of the region, but often will.

This is a precursor to improving our suppression heuristic.
<rdar://problem/12350829>

llvm-svn: 166940
2012-10-29 17:31:53 +00:00
Daniel Jasper d29d5fa3f2 Implement has(), hasDescendant(), forEach() and forEachDescendant() for
Types, QualTypes and TypeLocs.

Review: http://llvm-reviews.chandlerc.com/D83
llvm-svn: 166917
2012-10-29 10:14:44 +00:00
Mahesha S 19a429e7e6 Reverted back the changes made in 166868 and in 166869
llvm-svn: 166871
2012-10-27 10:44:42 +00:00
Mahesha S 5d61097dd9 Feature:
OpenMP support.

Sub-Feature:
  Support for "#pragma omp ..." registration with
  Preprocessor.

Files Changed/Added:
  * include/clang/Basic/DiagnosticGroups.td (C)
  * include/clang/Basic/DiagnosticParseKinds.td (C)
  * include/clang/Basic/TokenKinds.def (C)
  * include/clang/Parse/Parser.h (C)
  * lib/Parse/Parser.cpp (C)

Test Cases Changed/Added:
  * test/Preprocessor/pragma_omp.c (A)
  * test/Preprocessor/pragma_omp_ignored_warning.c (A)

llvm-svn: 166869
2012-10-27 09:05:45 +00:00
Mahesha S 6a682be48b -------------------------------------------------
Feature:
  OpenMP support in CLANG:

Sub-Feature: 
  Support for option -fopenmp

Files Changed/Added:
  * include/clang/Driver/Options.td (C)
  * include/clang/Basic/LangOptions.def (C)
  * lib/Driver/Tools.cpp (C)
  * lib/Frontend/CompilerInvocation.cpp (C)

Test Cases Changed/Added:
  * test/Driver/clang_fopenmp_opt.c (A)
-------------------------------------------------

llvm-svn: 166868
2012-10-27 07:47:56 +00:00
Rafael Espindola 9c006de3d3 Move two helper functions to AST so that sema can use them.
llvm-svn: 166853
2012-10-27 01:03:43 +00:00
Bill Wendling 208f61913d Fix grammar-o.
llvm-svn: 166759
2012-10-26 07:02:46 +00:00
Bill Wendling 9d1ee1175d Recommit Eric's code to validate ASM string's constraints and modifiers.
This code checks the ASM string to see if the output size is able to fit within
the variable specified as the output. For instance, scalar-to-vector conversions
may not really work. It's on by default, but can be turned off with a flag if
you think you know what you're doing.

This is placed under a flag ('-Wasm-operand-widths') and flag group ('-Wasm').

<rdar://problem/12284092>

llvm-svn: 166737
2012-10-25 23:28:48 +00:00
Ted Kremenek a5958869f6 TrackConstraintBRVisitor and ConditionBRVisitor can emit similar
path notes for cases where a value may be assumed to be null, etc.
Instead of having redundant diagnostics, do a pass over the generated
PathDiagnostic pieces and remove notes from TrackConstraintBRVisitor
that are already covered by ConditionBRVisitor, whose notes tend
to be better.

Fixes <rdar://problem/12252783>

llvm-svn: 166728
2012-10-25 22:07:10 +00:00
Chad Rosier 5c56364be9 [ms-inline asm] Add support for field lookup in the SemaCallback. Patch by Eli.
llvm-svn: 166723
2012-10-25 21:49:22 +00:00
Douglas Gregor d814a05f6b When capturing 'this' in a lambda, make sure to update the set of
array-index starting values for the 'this' capture. Fixes
<rdar://problem/12426831>.

llvm-svn: 166709
2012-10-25 18:39:16 +00:00
Manuel Klimek 8246d87db0 Adds the possibility to inject a callback that's called after each translation unit is processed.
This is important when one wants to deduplicate results during one run over a translation unit by pointer identity of AST nodes.

llvm-svn: 166671
2012-10-25 08:49:11 +00:00
Bill Wendling d75987dde9 Revert r166647 to rethink the patch...
llvm-svn: 166655
2012-10-25 00:32:44 +00:00
Douglas Gregor 164df7debd Remove the old predefines-buffer diffing code completely. It's been
replaced by the more efficient, cleaner preprocessor-option version
that occurs earlier in PCH validation.

llvm-svn: 166654
2012-10-25 00:30:23 +00:00
Douglas Gregor 55358ede64 The the preprocessor option validator to compute suggested
predefines. We're not quite ready to cut over to these suggested
predefines yet, however.

llvm-svn: 166648
2012-10-25 00:07:54 +00:00
Bill Wendling 753c8782df Add some support for diagnosing possibly mismatched constraint, type size and
modifiers. (From an idea by Eric...)
<rdar://problem/12284092>

llvm-svn: 166647
2012-10-25 00:05:55 +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 b6af6c23cd (De-)serialize the preprocessor options, including macros defined,
-include'd files, etc. 

llvm-svn: 166614
2012-10-24 20:05:57 +00:00
Douglas Gregor 1452ff155b Teach the preprocessor to hold onto the preprocessor options.
llvm-svn: 166599
2012-10-24 17:46:57 +00:00
Douglas Gregor e81699d938 Move PreprocessorOptions into the Lex library, and make it intrusively
reference-counted.

llvm-svn: 166587
2012-10-24 17:01:35 +00:00
Douglas Gregor 2d30236d16 (De-)serialize header search options.
llvm-svn: 166586
2012-10-24 16:50:34 +00:00
Douglas Gregor b85b9ccb76 Move HeaderSearchOptions into the Lex library, make it intrusively
reference-counted, and hold a reference to it in HeaderSearch.

llvm-svn: 166583
2012-10-24 16:19:39 +00:00
Douglas Gregor 5a2783d522 Undef SEMANTIC_VALUE_DIAGOPT appropriately
llvm-svn: 166579
2012-10-24 15:53:39 +00:00
Douglas Gregor c6317dbf5e (De-)serialize the file system options.
llvm-svn: 166577
2012-10-24 15:49:58 +00:00
Douglas Gregor 8263ffb268 Serialize DiagnosticOptions to the AST file.
llvm-svn: 166572
2012-10-24 15:17:15 +00:00
Manuel Klimek c268745011 Adds the possibility to run ASTMatchFinder over arbitrary AST nodes.
llvm-svn: 166567
2012-10-24 14:47:44 +00:00
Douglas Gregor 47c089624f Remove the HiddenWeakTemplateVTables CodeGen option. It's currently unused.
llvm-svn: 166561
2012-10-24 14:11:55 +00:00
Jordan Rose 746c06d0bc [analyzer] Replace -analyzer-no-eagerly-trim-egraph with graph-trim-interval.
After every 1000 CFGElements processed, the ExplodedGraph trims out nodes
that satisfy a number of criteria for being "boring" (single predecessor,
single successor, and more). Rather than controlling this with a cc1 option,
which can only disable this behavior, we now have an analyzer-config option,
'graph-trim-interval', which can change this interval from 1000 to something
else. Setting the value to 0 disables reclamation.

The next commit relies on this behavior to actually test anything.

llvm-svn: 166528
2012-10-23 23:59:05 +00:00
Douglas Gregor 7959178eb0 Use a .def file for most of the diagnostic options.
llvm-svn: 166520
2012-10-23 23:11:23 +00:00
Douglas Gregor 811db4eac4 Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.

llvm-svn: 166508
2012-10-23 22:26:28 +00:00
Eli Friedman 7d14b3c9b3 Add a new warning -Wmissing-variable-declarations, to warn about variables
defined without a previous declaration.  This is similar to
-Wmissing-prototypes, but for variables instead of functions.

Patch by Ed Schouten.

llvm-svn: 166498
2012-10-23 20:19:32 +00:00
Douglas Gregor b0eea8b54b Switch CodeGenOptions over to a .def file, like we do with LangOptions.
llvm-svn: 166497
2012-10-23 20:05:01 +00:00
Daniel Jasper b0c7b61730 Make hasDeclaration() matcher work inside the memberExpr() matcher.
llvm-svn: 166479
2012-10-23 15:46:39 +00:00
Manuel Klimek 7fca93b428 Implements the thisExpr matcher.
Patch by Gabor Horvath.

llvm-svn: 166477
2012-10-23 10:40: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
Eli Friedman d5d136be5b [ms-inline-asm] Add handling for errors coming out of the backend.
llvm-svn: 166463
2012-10-23 02:43:30 +00:00
Michael J. Spencer 7ccb6d9f8a [Options] Fix two options I mistransformed.
llvm-svn: 166458
2012-10-23 01:25:21 +00:00
Douglas Gregor 4b29c16eec Allow clients of the AST reader to specify what kinds of AST load
failures they know how to tolerate, e.g., out-of-date input files or
configuration/version mismatches. Suppress the corresponding
diagnostics if the client can handle it.

No clients actually use this functionality, yet.

llvm-svn: 166449
2012-10-22 23:51:00 +00:00
Douglas Gregor 4750b77ea1 Collapse ASTReader::ReadSLocEntryRecord() into its only caller,
ReadSLocEntry(). No functionality change.

llvm-svn: 166447
2012-10-22 22:53:10 +00:00
Douglas Gregor c9ad5fb604 Distinguish the various kinds of AST file loading failures:
file corruption, compiler version mismatch, target/language
configuration mismatch, out-of-date AST file. No functionality change
yet.

llvm-svn: 166446
2012-10-22 22:50:17 +00:00
Michael J. Spencer 929fccd476 [Options] Add prefixes to options.
Each option has a set of prefixes. When matching an argument such as
-funroll-loops. First the leading - is removed as it is a prefix. Then
a lower_bound search for "funroll-loops" is done against the option table by
option name. From there each option prefix + option name combination is tested
against the argument.

This allows us to support Microsoft style options where both / and - are valid
prefixes. It also simplifies the cases we already have where options come in
both - and -- forms. Almost every option for gnu-ld happens to have this form.

llvm-svn: 166444
2012-10-22 22:13:48 +00:00
Douglas Gregor 3120d2c389 Eliminate the redundancy between source-file information in the source
manager block and input-file information in the control block. The
source manager entries now point back into the control block. Input
files are now lazily deserialized (if validation is disabled). Reduces
Cocoa's PCH by the ~70k I added when I introduced the redundancy in
r166251.

llvm-svn: 166429
2012-10-22 18:42:04 +00:00
Daniel Jasper 632aea92a5 Implement hasParent()-matcher.
llvm-svn: 166421
2012-10-22 16:26:51 +00:00
Richard Smith c25be71426 PR14141 (part of DR1351): An implicitly-deduced "any" exception specification
produces an exception of 'noexcept(false)' and is thus compatible with an
explicit exception specification of 'noexcept(false)'.

llvm-svn: 166404
2012-10-21 23:00:34 +00:00
Lang Hames 720ae09c00 Fix typo, make test case slightly more reabable. Thanks to Dmitri Gribenko for
the suggestions.

llvm-svn: 166400
2012-10-21 19:56:13 +00:00
Richard Smith db2630fb04 Unrevert r166268, reverted in r166272, with a fix for the issue which Nick
found: if an overloaded operator& is present before a template definition,
the expression &T::foo is represented as a CXXOperatorCallExpr, not as a
UnaryOperator, so we didn't notice that it's permitted to reference a non-static
data member of an unrelated class.

While investigating this, I discovered another problem in this area: we are
treating template default arguments as unevaluated contexts during substitution,
resulting in performing incorrect checks for uses of non-static data members in
C++11. That is not fixed by this patch (I'll look into this soon; it's related
to the failure to correctly instantiate constexpr function templates), but was
resulting in this bug not firing in C++11 mode (except with -Wc++98-compat).

Original message:

PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.

llvm-svn: 166385
2012-10-21 03:28:35 +00:00
Lang Hames a930e7131c When used in a compound expression FP_CONTRACT should proceed all explicit
declarations and statements. Emit an error if the FP_CONTRACT is used
later in a compound statement.

llvm-svn: 166383
2012-10-21 01:10:01 +00:00
Richard Smith 6f21206850 DR1473: Do not require a space between operator"" and the ud-suffix in a
literal-operator-id.

llvm-svn: 166373
2012-10-20 08:41:10 +00:00
Richard Smith 66f3ac9d21 Rework implementation of DR1492: Apply the resolution to operator delete too,
since it also has an implicit exception specification. Downgrade the error to
an extwarn, since at least for operator delete, system headers like to declare
it as 'noexcept' whereas the implicit definition does not have an explicit
exception specification. Move the exception specification for user-declared
'operator delete' functions from the type-as-written into the type, to reflect
reality and to allow us to detect whether there was an implicit exception spec
or not.

llvm-svn: 166372
2012-10-20 08:26:51 +00:00
Nico Weber 206e0ecaa2 Accept -Wno-arc-abi without warning for a while.
Xcode 4.5 passes -Wno-arc-abi to clang, which makes a clang newer than
r163917 warn that it doesn't understand -Wno-arc-abi. I asked if adding
this is ok at
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20121015/066433.html
and nobody objected.

Adding this makes life a bit easier for the chromium project. If you think
this is a burden on for clang, shout, and I'll revert this.

llvm-svn: 166370
2012-10-20 06:18:14 +00:00
Argyrios Kyrtzidis 73ccdb9c15 When associating file ranges of macro arguments with their
macro expansion ranges, make sure to check all the FileID
entries that are contained in the spelling range of the
expansion for the macro argument.

Fixes rdar://12537982

llvm-svn: 166359
2012-10-20 00:51:32 +00:00
Michael J. Spencer 66e2b20d39 [Options] Make Option non clang specific.
llvm-svn: 166348
2012-10-19 22:37:06 +00:00
Michael J. Spencer fc790901d2 [Options] make Option a value type.
llvm-svn: 166347
2012-10-19 22:36:40 +00:00
Shuxin Yang 38860baad0 remove noreturn attribute from __builtin_debugtrap
llvm-svn: 166345
2012-10-19 22:21:42 +00:00
Shuxin Yang 57cc6aff5e add __builtin_debugtrap
llvm-svn: 166298
2012-10-19 20:09:33 +00:00
David Blaikie 82d3ab9225 Clarify wording of -Wshift-op-parentheses.
Suggestion from Matt Beaumont-Gay reviewing r165283.

llvm-svn: 166296
2012-10-19 18:26:06 +00:00
Dmitri Gribenko 923f305b2e Remove const_casts by propagating constness down to called functions.
llvm-svn: 166287
2012-10-19 16:51:38 +00:00
Jordan Rose 2afd661685 Allow objc_requires_super to be used to check class methods as well.
Also, unify ObjCShouldCallSuperDealloc and ObjCShouldCallSuperFinalize.
The two have identical behavior and will never be active at the same time.

There's one last simplification now, which is that if we see a call to
[super foo] and we are currently in a method named 'foo', we will
/unconditionally/ clear the ObjCShouldCallSuper flag, rather than check
first to see if we're in a method where calling super is required. There's
no reason to pay the extra lookup price here.

llvm-svn: 166285
2012-10-19 16:05:26 +00:00
Andy Gibbs 0fea04509a Change VerifyDiagnosticConsumer so that it *must* contain at least one "expected-*" directive. As a result, for test-cases that are not expected to generate any diagnostics, an additional directive "expected-no-diagnostics" has been implemented which can then be included in such test-cases. This new directive may not be used in conjunction with any other "expected-*" directive.
This change was initially proposed as a solution to the problem highlighted by check-in r164677, i.e. that -verify will not cause a test-case failure where the compile command does not actually reference the file.

Patch reviewed by David Blaikie.

llvm-svn: 166281
2012-10-19 12:49:32 +00:00
Nick Lewycky 2e3b716959 Revert r166268, this fix for a crash-on-invalid introduced a rejects-valid.
Richard has an unreduced testcase to work with.

llvm-svn: 166272
2012-10-19 08:08:02 +00:00
Richard Smith b2d6df5c95 PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.

llvm-svn: 166268
2012-10-19 06:32:17 +00:00
Nick Lewycky f20544aa52 Fix typo in comment.
llvm-svn: 166253
2012-10-19 00:47:07 +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
Argyrios Kyrtzidis f552d3841b Revert r166223 and the subsequent commits that depend on it, r166230 & r166235.
This seems to have introduced assertion hit when building compiler-rt.

llvm-svn: 166245
2012-10-18 22:42:31 +00:00
Eric Christopher a2f7eb7c52 Add a new option for and disable column number information as there
are no known current users of column info. Robustify and fix up
a few tests in the process. Reduces the size of debug information
by a small amount.

Part of PR14106

llvm-svn: 166236
2012-10-18 21:52:18 +00:00
Eric Christopher 1adabcf3f5 Remove trailing comma.
llvm-svn: 166235
2012-10-18 21:52:10 +00:00
Douglas Gregor 451dffaf64 Move OriginalDir from ASTReader to ModuleFile.
llvm-svn: 166233
2012-10-18 21:47:16 +00:00
Fariborz Jahanian 9d2f1e753b [doc parsing] use getParamName to access parameter
for current(rewritten) comment and getParamNameAsWritten
to access param name coming with \param marker.

llvm-svn: 166231
2012-10-18 21:42:42 +00:00
Michael J. Spencer 43897975cc [Options] Make Option non clang specific.
llvm-svn: 166230
2012-10-18 21:36:01 +00:00
Douglas Gregor 6bdae4b7c1 Move the "RelocatablePCH" bit from the ASTReader to the module file.
llvm-svn: 166229
2012-10-18 21:31:35 +00:00
Douglas Gregor e68c2cb502 Move information about the "original file" from the ASTReader into the
module files.

llvm-svn: 166228
2012-10-18 21:18:25 +00:00
Michael J. Spencer 842227a2e2 [Options] make Option a value type.
llvm-svn: 166223
2012-10-18 20:33:42 +00:00
Chad Rosier b91b3f88ad [ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback,
which will be used by the asm matcher in the near future.

llvm-svn: 166221
2012-10-18 20:27:06 +00:00
Eli Friedman eaf3414979 Fix Objective-C implicit property synthesis for C++ classes so we use valid
source locations in places where it is necessary for diagnostics.  By itself,
this causes assertions, so while I'm here, also fix property synthesis
for properties of C++ class type so we use so we properly set up a scope
and mark variable declarations.

<rdar://problem/12514189>.

llvm-svn: 166219
2012-10-18 20:14:08 +00:00
Anna Zaks 673d76b0bc Factor CollectClassPropertyImplementations out of Sema into AST
This would make it possible for the analyzer to use the function.

llvm-svn: 166210
2012-10-18 19:17:53 +00:00
Axel Naumann dd433f0b2f From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.
llvm-svn: 166208
2012-10-18 19:05:02 +00:00
Douglas Gregor fad10d8568 Collapse the original file name and original file ID records into a
single record. 

llvm-svn: 166206
2012-10-18 18:36:53 +00:00
Douglas Gregor 0aa21c98a6 Collapse the "version control revision/tag" AST file record into the
metadata record, which already had other version information. Clean up
the block info block along the way.

llvm-svn: 166204
2012-10-18 18:27:37 +00:00
Dmitri Gribenko a83d529369 Fix more documentation comments in Comment.h
llvm-svn: 166203
2012-10-18 18:21:40 +00:00
Dmitri Gribenko d0756e45a5 Expand the comment for DeclInfo::CurrentDecl.
llvm-svn: 166202
2012-10-18 18:18:26 +00:00
Douglas Gregor 4d3611ca82 Split the target options out into their own record within the AST
file's control block.

llvm-svn: 166195
2012-10-18 17:58:09 +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
Fariborz Jahanian a52fd9783f Improve comment in couple of fields of DeclInfo.
llvm-svn: 166192
2012-10-18 17:32:05 +00:00
Chad Rosier ce2bcbf8c0 [ms-inline asm] Move most of the AsmParsing logic in clang back into the MC
layer.  Use the new ParseMSInlineAsm() API and add an implementation of the
MCAsmParserSemaCallback interface.

llvm-svn: 166184
2012-10-18 15:49:40 +00:00
Douglas Gregor 112b907dbb Start factoring the on-disk records for an AST file into a control
block, which stores information about how the AST file to generated,
from the AST block, which stores the actual serialized AST. The
information in the control block should be enough to determine whether
the AST file is up-to-date and compatible with the current translation
unit, and reading it should not cause any side effects that aren't
easy to undo. That way, we can back out from an attempt to read an
incompatible or out-of-date AST file.

Note that there is still more factoring to do. In particular,
information about the source files used to generate the AST file
(along with their time stamps, sizes, etc.) still resides in the
source manager block. 

llvm-svn: 166166
2012-10-18 05:31:06 +00:00
Argyrios Kyrtzidis 5e2ec486bb [libclang] Invoke a ppIncludedFile callback when indexing implicit module imports.
llvm-svn: 166161
2012-10-18 00:17:05 +00:00
Richard Smith 87e795174c DR1528: C++11 doesn't allow repeated cv-qualifiers in declarators after all.
llvm-svn: 166152
2012-10-17 23:31:46 +00:00
Fariborz Jahanian 3ce7e04a53 Adds couple of missing warning flags so warnings can be turned
off. // rdar://12501960

llvm-svn: 166150
2012-10-17 23:19:22 +00:00
Richard Smith 460fe6ba47 Add -std=c++1y argument, for *highly* experimental C++14 support.
llvm-svn: 166139
2012-10-17 23:07:52 +00:00
Fariborz Jahanian a7d76d2672 [Doc parsing]: This patch adds <Declaration> tag to
XML comment for declarations which pretty-prints
declaration. I had to XFAIL one test annotate-comments.cpp.
This test is currently unmaintainable as written.
Dmitri G., can you see what we can do about this test.
We should change this test such that adding a new tag does not wreck
havoc to the test.

llvm-svn: 166130
2012-10-17 21:58:03 +00:00
Jordan Rose 8e785e214b [analyzer] When binding to a ParenExpr, bind to its inner expression instead.
This actually looks through several kinds of expression, such as
OpaqueValueExpr and ExprWithCleanups. The idea is that binding and lookup
should be consistent, and so if the environment needs to be modified later,
the code doing the modification will not have to manually look through these
"transparent" expressions to find the real binding to change.

This is necessary for proper updating of struct rvalues as described in
the previous commit.

llvm-svn: 166121
2012-10-17 19:35:44 +00:00
David Blaikie 56a12cea13 Move -Wint-to-pointer-cast from -Wall to -Wmost to group it with more things.
Addressing feedback on r166039 given by Matt Beaumont-Gay.

llvm-svn: 166118
2012-10-17 18:47:30 +00:00
Daniel Jasper 516b02e548 First version of matchers for Types and TypeLocs.
Review: http://llvm-reviews.chandlerc.com/D47
llvm-svn: 166094
2012-10-17 08:52:59 +00:00
John McCall 0d54a17b52 Set a special flag in class metadata when an Objective-C class
has ivars that require destruction, but none that require anything
except zero-initialization.  This is common in ARC and (when true
throughout a class hierarchy) permits the elimination of an
unnecessary message-send during allocation.

llvm-svn: 166088
2012-10-17 04:53:31 +00:00
David Blaikie 7e414261f6 Implement C++ 10.3p16 - overrides involving deleted functions must match.
Only deleted functions may override deleted functions and non-deleted functions
may only override non-deleted functions.

llvm-svn: 166082
2012-10-17 00:47:58 +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
Derek Schuff a202096dc0 Add pnaclcall convention to Native Client targets.
Because PNaCl bitcode must be target-independent, it uses some
different bitcode representations from other targets (e.g. byval and
sret for structures). This means that without additional type
information, it cannot meet some native ABI requirements for some
targets (e.g. passing structures containing unions by value on
x86-64). To allow generation of code which uses the correct native
ABIs, we also support triples such as x86_64-nacl, which uses
target-dependent IR (as opposed to le32-nacl, which uses byval and
sret).

To allow interoperation between the two types of code, this patch adds
a calling convention attribute to be used in code compiled with the
target-dependent triple, which will generate code using the le32-style
bitcode. This calling convention does not need to be explicitly
supported in the backend because it determines bitcode representation
rather than native conventions (the backend just needs to undersand
how to handle byval and sret for the Native Client OS).

This patch implements __attribute__((pnaclcall)) to generate calls in
bitcode according to the le32 bitcode conventions, an attribute which
is accepted by any Native Client target, but issues a warning
otherwise.

llvm-svn: 166065
2012-10-16 22:30:41 +00:00
Chad Rosier f8037a1fb6 [ms-inline asm] Move some logic around to simplify the interface between the
front-end and the AsmParser.  No functional change intended.

llvm-svn: 166063
2012-10-16 21:55:39 +00:00
David Blaikie 282ad876bd Implement GCC's -Wint-to-pointer-cast.
This implementation doesn't warn on anything that GCC doesn't warn on with the
exception of templates specializations (GCC doesn't warn, Clang does). The
specific skipped cases (boolean, constant expressions, enums) are open for
debate/adjustment if anyone wants to demonstrate that GCC is being overly
conservative here. The only really obvious false positive I found was in the
Clang regression suite's MPI test - apparently MPI uses specific flag values in
pointer constants. (eg: #define FOO (void*)~0)

llvm-svn: 166039
2012-10-16 18:53:14 +00:00
Daniel Dunbar bd847cc562 Un-revert r164907 and r164902 (+ follow-ups), 10.6 build fix to follow.
llvm-svn: 165988
2012-10-15 22:23:53 +00:00
Fariborz Jahanian bbd469bef3 Fixes location of overriding declaration with no comment
of their own.

llvm-svn: 165972
2012-10-15 20:57:52 +00:00
Nico Weber bec2bf1326 Revert r164907 and r164902 (+ follow-ups). They broke building on 10.6.
See PR14013.

llvm-svn: 165962
2012-10-15 20:37:01 +00:00
Fariborz Jahanian 14ec3f3acb structured document comment: patch to provide comment for overriding function
template when comment is comming from overridden declaration. 
// rdar://12378793

llvm-svn: 165953
2012-10-15 18:58:50 +00:00
Douglas Gregor bc10b9fbc5 Teach TargetInfo to hold on to the TargetOptions with which it was
created.

llvm-svn: 165943
2012-10-15 16:45:32 +00:00
Douglas Gregor 5952766628 Introduce the notion of excluded headers into the module map
description. Previously, one could emulate this behavior by placing
the header in an always-unavailable submodule, but Argyrios guilted me
into expressing this idea properly.

llvm-svn: 165921
2012-10-15 06:28:11 +00:00
Benjamin Kramer 66cd0503b8 Simplify code. No functionality change.
llvm-svn: 165905
2012-10-14 11:50:50 +00:00
Jordan Rose 690c063b73 [analyzer] Remove the "direct bindings only" Environment lookup.
This was only used by OSAtomicChecker and makes it more
difficult to update values for expressions that the environment
may look through instead (it's not the same as IgnoreParens).
With this gone, we can have bindExpr bind to the inner
expression that getSVal will find.

Groundwork for <rdar://problem/12137950>

llvm-svn: 165866
2012-10-13 05:05:20 +00:00
Jordan Rose 88b690dd2e [analyzer] Remove unneeded 'inlineCall' checker callback.
I believe the removed assert in CheckerManager says it best:

	InlineCall is a special hacky callback to allow intrusive
	evaluation of the call (which simulates inlining). It is
	currently only used by OSAtomicChecker and should go away
	at some point.

OSAtomicChecker has gone away; inlineCall can now go away as well!

llvm-svn: 165865
2012-10-13 05:05:13 +00:00