Commit Graph

14506 Commits

Author SHA1 Message Date
Eric Christopher feb1ede964 Silence anonymous type in anonymous union warnings.
llvm-svn: 177133
2013-03-15 00:32:52 +00:00
Argyrios Kyrtzidis 3e56dd4fc9 Don't try to typo-correct 'super' in an objc method.
This created 2 issues:

1) Performance issue, since typo-correction with PCH/modules is rather expensive.
2) Correctness issue, since if it managed to "correct" 'super' then bogus compiler errors would
be emitted, like this:

3.m:8:3: error: unknown type name 'super'; did you mean 'super1'?
  super.x = 0;
  ^~~~~
  super1
t3.m:5:13: note: 'super1' declared here
typedef int super1;
            ^
t3.m:8:8: error: expected identifier or '('
  super.x = 0;
       ^

llvm-svn: 177126
2013-03-14 22:56:43 +00:00
Anna Zaks 2672a4cc0c [analyzer] Change the way in which IDC Visitor decides to kick in and make sure it attaches in the given edge case
In the test case below, the value V is not constrained to 0 in ErrorNode but it is in node N.
So we used to fail to register the Suppression visitor.

We also need to change the way we determine that the Visitor should kick in because the node N belongs to
the ExplodedGraph and might not be on the BugReporter path that the visitor sees. Instead of trying to match the node,
turn on the visitor when we see the last node in which the symbol is ‘0’.

llvm-svn: 177121
2013-03-14 22:31:56 +00:00
Chandler Carruth 5aa9d793c5 Fix an unused variable warning from Clang by sinking a dyn_cast into an
isa and a cast inside the assert. The efficiency concern isn't really
important here. The code should likely be cleaned up a bit more,
especially getting a message into the assert.

Please review Rafael.

llvm-svn: 177053
2013-03-14 11:17:20 +00:00
Joey Gouly 0608ae89a2 Add support for the 'endian' attribute for OpenCL.
llvm-svn: 177035
2013-03-14 09:54:43 +00:00
Rafael Espindola 0e0d00976f Avoid computing the linkage too early. Don't invalidate it.
Before this patch we would compute the linkage lazily and cache it. When the
AST was modified in ways that could change the value, we would invalidate the
cache.

That was fairly brittle, since any code could ask for the a linkage before
the correct value was available.

We should change the API to one where the linkage is computed explicitly and
trying to get it when it is not available asserts.

This patch is a first step in that direction. We still compute the linkage
lazily, but instead of invalidating a cache, we assert that the AST
modifications didn't change the result.

llvm-svn: 176999
2013-03-14 03:07:35 +00:00
Argyrios Kyrtzidis b146baabad [Modules] Don't eagerly load and associate all the module header files.
In a module-enabled Cocoa PCH file, we spend a lot of time stat'ing the headers
in order to associate the FileEntries with their modules and support implicit
module import.

Use a more lazy scheme by enhancing HeaderInfoTable to store extra info about
the module that a header belongs to, and associate it with its module only when
there is a request for loading the header info for a particular file.

Part of rdar://13391765

llvm-svn: 176976
2013-03-13 21:13:51 +00:00
Argyrios Kyrtzidis 3c5305c15e [Modules] Resolve top-headers of modules lazily.
This allows resolving top-header filenames of modules to FileEntries when
we need them, not eagerly.

Note that that this breaks ABI for libclang functions
clang_Module_getTopLevelHeader / clang_Module_getNumTopLevelHeaders
but this is fine because they are experimental and not widely used yet.

llvm-svn: 176975
2013-03-13 21:13:43 +00:00
Bob Wilson 897ce8c8bb Revert "Revert r166370 and r166540 now that Xcode 4.6 has been available for a while."
This reverts commit 176887.  Nico asked for more time to move to Xcode 4.6.

llvm-svn: 176892
2013-03-12 20:00:34 +00:00
Fariborz Jahanian 9d25a48b41 Objective-C: Issue warning in couple of obscure cases
when property autosynthesis does not synthesize a property.
When property is declared 'readonly' in a super class and
is redeclared 'readwrite' in a subclass. When a property
autosynthesis causes it to share 'ivar' with another property.
// rdar://13388503

llvm-svn: 176889
2013-03-12 19:46:17 +00:00
Bob Wilson 8859471c51 Revert r166370 and r166540 now that Xcode 4.6 has been available for a while.
Those changes were added as a temporary workaround for Xcode 4.5 passing the
-Wno-arc-abi option.  Xcode 4.6 does not pass that option so this should no
longer be necessary.

llvm-svn: 176887
2013-03-12 19:39:19 +00:00
Ted Kremenek 6209366e81 Revert "Disallow using -fmodules with -no-integrated-as."
Per comment from Benjamin Kramer, this isn't portable (yet).  I'll come up
with a better fix.

llvm-svn: 176876
2013-03-12 17:02:12 +00:00
Ted Kremenek 4b3ecba537 Disallow using -fmodules with -no-integrated-as.
Modules enables features such as auto-linking, and we simply do not want to
support a matrix of subtly enabled/disabled features depending on whether or
not a user is using the integrated assembler.

It isn't clear if this is the best place to do this check.  For one thing,
these kind of errors are not caught by the serialized diagnostics.

Fixes <rdar://problem/13289240>

llvm-svn: 176826
2013-03-11 20:51:52 +00:00
Richard Smith 06d274fdb7 Add -Wc99-compat warning for C11 unicode string and character literals.
llvm-svn: 176817
2013-03-11 18:01:42 +00:00
Richard Smith c98bb4ed99 Handle _Pragma on a u8, u, or U string literal per the C11 specification. Also
handle raw string literals here. C++11 doesn't yet specify how they will
behave, but discussion on core suggests that we should just strip off
everything but the r-char-sequence.

llvm-svn: 176779
2013-03-09 23:30:15 +00:00
Benjamin Kramer d235d37d27 Remove unused diagnostic.
llvm-svn: 176774
2013-03-09 18:44:47 +00:00
Anna Zaks 5497d1a55c [analyzer] Make Suppress IDC checker aware that it might not start from the same node it was registered at
The visitor used to assume that the value it’s tracking is null in the first node it examines. This is not true.
If we are registering the Suppress Inlined Defensive checks visitor while traversing in another visitor
(such as FindlastStoreVisitor). When we restart with the IDC visitor, the invariance of the visitor does
not hold since the symbol we are tracking no longer exists at that point.

I had to pass the ErrorNode when creating the IDC visitor, because, in some cases, node N is
neither the error node nor will be visible along the path (we had not finalized the path at that point
and are dealing with ExplodedGraph.)

We should revisit the other visitors which might not be aware that they might get nodes, which are
later in path than the trigger point.

This suppresses a number of inline defensive checks in JavaScriptCore.

llvm-svn: 176756
2013-03-09 03:23:19 +00:00
John McCall 5ea9577016 Add TagDecl::hasNameForLinkage(), which is true if the tag
is non-anonymous or is defined in a typedef of itself.

llvm-svn: 176742
2013-03-09 00:54:27 +00:00
Fariborz Jahanian cfbac5d317 Documentation parsing. Some refactoring and code
improvements per Dmtiri's comments. // rdar://12379114

llvm-svn: 176739
2013-03-08 23:59:23 +00:00
Argyrios Kyrtzidis 51c3318b01 [libclang] Change clang_findReferencesInFile and clang_findIncludesInFile to return an enum,
as suggested by Jordan.

llvm-svn: 176732
2013-03-08 22:47:41 +00:00
Jordan Rose a0a86bed71 Sema: Preserve attributes on parameters in instantiated function templates.
This was causing correctness issues for ARC and the static analyzer when a
function template has "consumed" Objective-C object parameters (i.e.
parameters that will be released by the function before returning).

The fix is threefold:
(1) Actually copy over the attributes from old ParmVarDecls to new ones.
(2) Have Sema::BuildFunctionType only work for building FunctionProtoTypes,
    which it was doing anyway. This allows us to pass an ExtProtoInfo
    instead of a plain ExtInfo and several flags.
(3) Drop param attributes as part of StripImplicitInstantiation, which is
    used when an implicit instantiation is followed by an explicit one.

<rdar://problem/12685622>

llvm-svn: 176728
2013-03-08 22:25:36 +00:00
Jordan Rose 5c38272c1a ArrayRef-ize ASTContext::getFunctionType and Sema::BuildFunctionType.
No (intended) functionality change.

llvm-svn: 176726
2013-03-08 21:51:21 +00:00
Argyrios Kyrtzidis c4720399ec [PCH] When complaining that a header from the PCH was modified, also mention
the filename of the PCH file.

llvm-svn: 176717
2013-03-08 20:42:38 +00:00
Argyrios Kyrtzidis 951f61fae2 [libclang] Modify clang_findReferencesInFile and clang_findIncludesInFile to return a value.
Possible values are:
 1  : if a parameter was invalid
 -1 : if the callback returned CXVisit_Break,
 otherwise returns 0.

llvm-svn: 176716
2013-03-08 20:42:33 +00:00
Joey Gouly aba589cceb Add support for the OpenCL attribute 'vec_type_hint'.
Patch by Murat Bolat!

llvm-svn: 176686
2013-03-08 09:42:32 +00:00
Argyrios Kyrtzidis 503c83ad81 [libclang] Introduce clang_findIncludesInFile, that can be used to retrieve all #import/#include directives in a specific file.
It passes to the visitor, that the caller provides, CXCursor_InclusionDirective cursors for
all the include directives in a particular file.

llvm-svn: 176682
2013-03-08 02:32:34 +00:00
Chad Rosier 09d607ecf1 [driver] If we're just linking, don't report --param X as unused option.
PR15327
rdar://13372628

llvm-svn: 176670
2013-03-08 00:05:21 +00:00
Fariborz Jahanian a649eee9e8 HeaderDoc: Support more of HeaderDoc documentation
commands; top level tags such as @interface and
their 2nd level tags such as @coclass, etc.
// rdar://12379114

llvm-svn: 176667
2013-03-07 23:33:11 +00:00
John McCall b1b5d0b1e8 Add CharUnits::alignmentAtOffset.
llvm-svn: 176655
2013-03-07 21:37:02 +00:00
Edwin Vane 2a760d02f7 Adding lvalue and rvalue reference type matchers
Updated docs and tests.
    
Reviewers: klimek, gribozavr

llvm-svn: 176630
2013-03-07 15:44:40 +00:00
Matthew Curtis 7ab8b2b2e0 Minor refactor of how we get compilation phases.
There is now a single function to get the list of phases for a given
output Type.

No functionality change intended.

llvm-svn: 176628
2013-03-07 12:32:26 +00:00
Nick Lewycky 737a452173 Add flags for additional control over coverage generation. Pick the version
string to be emitted, and two properties about the files themselves.

Use $PWD to absolut-ify the path to the coverage file. Yes, this is what GCC
does. Reverts my own r175706.

llvm-svn: 176617
2013-03-07 08:28:53 +00:00
Rafael Espindola 2199c126f5 Don't duplicate function names. Thanks to Jordan Rose for pointing it out.
llvm-svn: 176609
2013-03-07 02:43:24 +00:00
Rafael Espindola 45b620aab5 Add a hasExternalLinkage helper. No functionality change.
llvm-svn: 176607
2013-03-07 02:00:27 +00:00
Rafael Espindola 8f326a5a39 Add a hasExternalStorageAsWritten helper. No functionality change.
It is possible that some of the current uses of
"getStorageClassAsWritten() == SC_Extern" should use this but I don't know
enough about SC_PrivateExtern to change and test them.

llvm-svn: 176606
2013-03-07 01:42:44 +00:00
Rafael Espindola ee86f00f6e Fix typo.
llvm-svn: 176603
2013-03-07 01:34:57 +00:00
Jordan Rose 6f09928d5b [analyzer] Clean up a few doc comments for ProgramState and CallEvent.
No functionality change.

llvm-svn: 176600
2013-03-07 01:23:14 +00:00
Adrian Prantl a03a85a425 Ensure that DIType is regenerated after we visit an implementation
that adds ivars to an interface.

Fixes rdar://13175234

This is an update to r176116 that performs a smart caching of interfaces.

llvm-svn: 176584
2013-03-06 22:03:30 +00:00
Anna Zaks 6fe2fc633a [analyzer] IDC: Add config option; perform the idc check on first “null node” rather than last “non-null”.
The second modification does not lead to any visible result, but, theoretically, is what we should
have been looking at to begin with since we are checking if the node was assumed to be null in
an inlined function.

llvm-svn: 176576
2013-03-06 20:25:59 +00:00
Argyrios Kyrtzidis 61a3896d9f [PCH] We don't need to instantiate HeaderFileInfoTrait in ASTReader more than once.
We can just re-use the one from HeaderFileInfoLookupTable.

llvm-svn: 176565
2013-03-06 18:12:44 +00:00
Fariborz Jahanian ff81b824a2 Spell Objective-C correctly.
llvm-svn: 176563
2013-03-06 17:55:30 +00:00
Fariborz Jahanian 41bb7131b3 say objective-C in the warning and streamline
several diagnostics into one. // rdar://13094352

llvm-svn: 176560
2013-03-06 17:36:51 +00:00
Edwin Vane 0a4836ed0e New ASTMatchers and enhancement to hasOverloadedOperatorName
Added two new narrowing matchers:
* hasMethod: aplies a matcher to a CXXRecordDecl's methods until a match is made
  or there are no more methods.
* hasCanonicalType: applies a matcher to a QualType's canonicalType.

Enhanced hasOverloadedOperatorName to work on CXXMethodDecl as well as
CXXOperatorCallExpr.

Updated tests and docs.

Reviewers: klimek, gribozavr
llvm-svn: 176556
2013-03-06 17:02:57 +00:00
Weiming Zhao ff2a3ad81b revert r176531 due to clan-native-arm fails
llvm-svn: 176544
2013-03-06 02:08:54 +00:00
Richard Smith 5afcdf3f1c PR15390: If a function returns a pointer to a function, that function type
can't have default arguments even though it's a parameter-declaration-clause in
a function declaration.

llvm-svn: 176542
2013-03-06 01:37:38 +00:00
Richard Smith 7b24254e91 After issuing a diagnostic for undefining or redefining a builtin macro,
continue parsing the directive rather than silently discarding it.

Allowing undef or redef of __TIME__ and __DATE__ is important to folks
who want stable, reproducible builds.

llvm-svn: 176540
2013-03-06 00:46:00 +00:00
Weiming Zhao a35cc6fb6b PR 11326: Lack diagnosic message when ABI conflicts on ARM
When both Triple and -mabi are used, it may result into conflicting ABI value.

llvm-svn: 176531
2013-03-05 23:27:21 +00:00
Fariborz Jahanian a668bf548d fix a missing check in my last patch.
// rdar://13094352

llvm-svn: 176529
2013-03-05 23:20:29 +00:00
Fariborz Jahanian 56fe4066e5 doc. parsing. Improve on diagnostics on my last patch.
// rdar://13094352.

llvm-svn: 176525
2013-03-05 22:46:07 +00:00
Argyrios Kyrtzidis 37f2ab4824 [libclang] When logging a CXTranslationUnit that came from an AST file, print out the filename.
llvm-svn: 176511
2013-03-05 20:21:14 +00:00
Fariborz Jahanian f4ba35d809 doc parsing. Add @method and @callback for
checkings and few other refactoring/cleanup.
// rdar://13094352.

llvm-svn: 176509
2013-03-05 19:40:47 +00:00
David Blaikie e750491ff3 Add quotation marks to template names in diagnostics.
llvm-svn: 176474
2013-03-05 06:21:38 +00:00
Jordan Rose d03d99da16 Silence a number of static analyzer warnings with assertions and such.
No functionality change.

llvm-svn: 176469
2013-03-05 01:27:54 +00:00
Fariborz Jahanian 8a7a59226d doc parsing. We want to issue a strong warning when
an @function comment is not followed by a function decl.
// rdar://13094352

llvm-svn: 176468
2013-03-05 01:05:07 +00:00
Dmitri Gribenko bcf7f4d3bb Comment parsing: refactor handling of command markers in AST
* Use the term 'command marker', because the semantics of 'backslash' and 'at'
  commands are the same.  (Talking about 'at commands' makes them look like a
  special entity.)

* Sink the flag down into bitfields, reducing the size of AST nodes.

* Change the flag into an enum for clarity.  Boolean function parameters are
  not very clear.

* Add unittests for new tok::at_command tokens.

llvm-svn: 176461
2013-03-04 23:06:15 +00:00
Argyrios Kyrtzidis 2a513e8218 [PCH] In HeaderFileInfoTrait::EqualKey(), use FileManager::getFile() to compare two filenames, instead of llvm::sys::fs::equivalent().
llvm::sys::fs::equivalent() does 2 stat calls every time it's called. Use FileManager::getFile() to take advantage
of the stat caching that FileManager is providing.

llvm-svn: 176450
2013-03-04 20:33:40 +00:00
Fariborz Jahanian c551ecc8f0 [comment parsing] source fidelity for tparam command too.
// rdar://13066276

llvm-svn: 176448
2013-03-04 20:08:47 +00:00
Fariborz Jahanian 5f2a813d2a comment parsing. Missed a case of referring
to original command in diagnostic. // rdar://13066276

llvm-svn: 176444
2013-03-04 18:53:41 +00:00
Edwin Vane 6972f6d3c7 hasQualifer() matcher should return false if there's no qualifier
Instead of passing NULL on to sub-matcher, just return false. Updated tests and
regenerated docs.

Author: Tareq A Siraj <tareq.a.siraj@intel.com>
llvm-svn: 176441
2013-03-04 17:51:00 +00:00
John McCall cc5788c5ce Centralize and refine the __unknown_anytype argument rules
and be sure to apply them whether or not the debugger gave
us a method declaration.

rdar://12565338

llvm-svn: 176432
2013-03-04 07:34:02 +00:00
David Chisnall e0a5c0d914 Default to enabling default-synthesized ivars on all platforms
llvm-svn: 176419
2013-03-03 15:36:10 +00:00
Rafael Espindola de6a39f759 Process #pragma weak only after we know the linkage of the function or variable
we are looking at.

llvm-svn: 176414
2013-03-02 21:41:48 +00:00
Anna Zaks 8d7c8a4dd6 [analyzer] Simple inline defensive checks suppression
Inlining brought a few "null pointer use" false positives, which occur because
the callee defensively checks if a pointer is NULL, whereas the caller knows
that the pointer cannot be NULL in the context of the given call.

This is a first attempt to silence these warnings by tracking the symbolic value
along the execution path in the BugReporter. The new visitor finds the node
in which the symbol was first constrained to NULL. If the node belongs to
a function on the active stack, the warning is reported, otherwise, it is
suppressed.

There are several areas for follow up work, for example:
 - How do we differentiate the cases where the first check is followed by
another one, which does happen on the active stack?

Also, this only silences a fraction of null pointer use warnings. For example, it
does not do anything for the cases where NULL was assigned inside a callee.

llvm-svn: 176402
2013-03-02 03:20:52 +00:00
Fariborz Jahanian e400cb70d4 Some refactoring in my patch on document
command source fidelity. // rdar://13066276

llvm-svn: 176401
2013-03-02 02:39:57 +00:00
Fariborz Jahanian d49963609d comment parsing. Keep the original command format
in AST for source fidelity and use it in diagnostics 
to refer to the original format. // rdar://13066276

llvm-svn: 176387
2013-03-01 22:51:30 +00:00
Stefanus Du Toit b331850194 Fix typos: [Dd]iagnosic -> [Dd]iagnostic
These all appear in comments or (ironically) diagnostics output.

llvm-svn: 176383
2013-03-01 21:41:22 +00:00
John McCall 73fc0385de Attempt to not place ownership qualifiers on the result type
of block declarators.  Document the rule we use.

Also document the rule that Doug implemented a few weeks ago
which drops ownership qualifiers on function result types.

rdar://10127067

llvm-svn: 176336
2013-03-01 07:58:16 +00:00
Argyrios Kyrtzidis 61c3d8778c [PCH] Enhance InputFile to also include whether the file is out-of-date.
Previously we would return null for an out-of-date file. This inhibited ASTReader::ReadSLocEntry
from creating a FileID to recover gracefully in such a case.

llvm-svn: 176332
2013-03-01 03:26:04 +00:00
Fariborz Jahanian a1b9b3f599 Fix warning text of my last patch.
// rdar://13158394

llvm-svn: 176308
2013-02-28 23:16:39 +00:00
Fariborz Jahanian d838bba59b objective-C: clang, following gcc, warns on
use of stand-alone protocol as type and uses
id<proto>. Modify warning to say what compiler 
is doing. // rdar//13158394

llvm-svn: 176303
2013-02-28 22:36:31 +00:00
Manuel Klimek bd5ac98277 Fix a problem where 'clang' is ambiguous in MSVC builds.
llvm-svn: 176275
2013-02-28 18:12:44 +00:00
Manuel Klimek d4be4084b4 First step towards adding a parent map to the ASTContext.
This does not yet implement the LimitNode approach discussed.

The impact of this is an O(n) in the number of nodes in the AST
reduction of complexity for certain kinds of matchers (as otherwise the
parent map gets recreated for every new MatchFinder).

See FIXMEs in the comments for the direction of future work.

llvm-svn: 176251
2013-02-28 13:21:39 +00:00
Jordan Rose 4879e49c8e [analyzer] Mark the root SVal class as isPodLike.
Pure optimization, no functionality change. Probably does not make much
of a difference, but it's free.

llvm-svn: 176229
2013-02-28 01:53:03 +00:00
Rafael Espindola 679eb4062b Don't cache the visibility of types.
Since r175326 an implicitly hidden template argument can cause a template
installation to become hidden, even if the template itself has an explicit
default visibility. This requires that we keep track of "late" additions
of the visibility attribute.

This is hopefully the last followup change. It just removes the caching of
visibilities from types so that we can see new attributes even after a type has
been used.

llvm-svn: 176164
2013-02-27 04:15:01 +00:00
Rafael Espindola 4a5da44b34 Rename methods to comply with the LLVM Coding Standards.
llvm-svn: 176159
2013-02-27 02:56:45 +00:00
Rafael Espindola 6fbfafeddc Change Type::getLinkageAndVisibility to return a LinkageInfo.
llvm-svn: 176157
2013-02-27 02:27:19 +00:00
Rafael Espindola a8fbdab850 Move LinkageInfo out of NamedDecl so that it can be used in Type.h.
Everything that cares about visibility also cares about linkage, so I just
moved it to Visibility.h instead of creating a new .h.

llvm-svn: 176155
2013-02-27 02:15:29 +00:00
Adrian Prantl 68a5750d5d Temporarily revert r176116 for compile-time performance regression.
This reverts commit ea95e4587fd13606fbf63b10a07a7d02026aa39c.

llvm-svn: 176151
2013-02-27 01:31:55 +00:00
Fariborz Jahanian 81bbee1ed8 comment parsing: Properties are considered like methods, and people
think of them as having return values that may be computed. Don't
warn when using @return in their comment. // rdar://13189938

llvm-svn: 176147
2013-02-27 00:46:06 +00:00
Ted Kremenek 08037045f8 Refine SourceManager's isBeforeInTranslationUnit() cache to have more entries.
isBeforeInTranslationUnit() uses a cache to reduce the expensive work
to compute a common ancestor for two FileIDs.  This work is very
expensive, so even caching the latest used FileIDs was a big win.
A closer analysis of the cache before, however, shows that the cache
access pattern would oscillate between a working set of FileIDs, and
thus caching more pairs would be profitable.

This patch adds a side table for extending caching.  This side table
is bounded in size (experimentally determined in this case from
a simple Objective-C project), and when the table gets too large
we fall back to the single entry caching before as before.

On Sketch (a small example Objective-C project), this optimization
reduces -fsyntax-only time on SKTGraphicView.m by 5%.  This is
for a project that is already using PCH.

Fixes <rdar://problem/13299847>

llvm-svn: 176142
2013-02-27 00:00:26 +00:00
Fariborz Jahanian 828b8d2415 doxygen command. Add 'attention' command to list of similar
doxygen commands. // rdar://12379053

llvm-svn: 176127
2013-02-26 22:12:16 +00:00
Matt Arsenault 376f72092c Fix assertion failure when a field is given an address space.
llvm-svn: 176122
2013-02-26 21:16:00 +00:00
Adrian Prantl 71510db7bc Ensure that DIType is regenerated after we visited an implementation that adds ivars to an interface. Fixes rdar://13175234
llvm-svn: 176116
2013-02-26 20:01:46 +00:00
Kostya Serebryany 4c0fc9931e Unify clang/llvm attributes for asan/tsan/msan (Clang part)
These are two related changes (one in llvm, one in clang).
LLVM: 
- rename address_safety => sanitize_address (the enum value is the same, so we preserve binary compatibility with old bitcode)
- rename thread_safety => sanitize_thread
- rename no_uninitialized_checks -> sanitize_memory

CLANG: 
- add __attribute__((no_sanitize_address)) as a synonym for __attribute__((no_address_safety_analysis))
- add __attribute__((no_sanitize_thread))
- add __attribute__((no_sanitize_memory))

for S in address thread memory
If -fsanitize=S is present and __attribute__((no_sanitize_S)) is not
set llvm attribute sanitize_S

llvm-svn: 176076
2013-02-26 06:58:27 +00:00
Edwin Vane b6eae14c15 Various additions to ASTMatcher library:
New type matchers:
* recordType
* elaboratedType

New narrowing matchers:
* hasQualifier
* namesType
* hasDeclContext

Added tests and updated LibASTMatchersReference.

Reviewers: klimek
llvm-svn: 176047
2013-02-25 20:43:32 +00:00
Anna Zaks 2d773b8138 [analyzer] Address Jordan's code review of r175857.
llvm-svn: 176043
2013-02-25 19:50:50 +00:00
Edwin Vane f901b71921 Adding hasDeclaration overload for TemplateSpecializationType
TemplateSpecializationType doesn't quite have getDecl(). Need to go
through TemplateName to get a TemplateDecl.

Added test cases for the hasDeclaration() overload for
TemplateSpecializationType. Also introduced the type matcher
templateSpecializationType() used by the new hasDeclaration() test case.

Updated LibASTMatchersReference.

Reviewers: klimek
llvm-svn: 176025
2013-02-25 14:49:29 +00:00
Edwin Vane ed93645739 Support in hasDeclaration for types with getDecl()
Re-introducing r175532. The has_getDecl metafunction didn't compile with
Visual Studio. This revision uses approaches has_getDecl from a
different angle that isn't a problem for Visual Studio.

Added dedicated tests for the metafunction.

Reviewers: klimek
llvm-svn: 176024
2013-02-25 14:32:42 +00:00
Edwin Vane d0dfa07b44 Reverting r176019. Corrupt patch.
llvm-svn: 176021
2013-02-25 14:09:28 +00:00
Edwin Vane 8342598d1b Support in hasDeclaration for types with getDecl()
Re-introducing r175532. The has_getDecl metafunction didn't compile with Visual
Studio. This revision approaches has_getDecl from a different angle that isn't
a problem for Visual Studio.

Added dedicated tests for the metafunction.

Reviewers: klimek
llvm-svn: 176019
2013-02-25 13:59:06 +00:00
Daniel Jasper 639522ca35 Add matcher for AccessSpecDecls.
Also, add matchers isPrivate(), isProtected() and isPublic(), that
restrict the matching of such AccessSpecDecls and all other Decls.

llvm-svn: 176017
2013-02-25 12:02:08 +00:00
Ted Kremenek 04fa9e3d80 [analyzer] add the notion of an "interesting" lvalue expression for ExplodedNode pruning.
r175988 modified the ExplodedGraph trimming algorithm to retain all
nodes for "lvalue" expressions.  This patch refines that notion to
only "interesting" expressions that would be used for diagnostics.

llvm-svn: 176010
2013-02-25 07:37:13 +00:00
Ted Kremenek 9625048278 [analyzer] tracking stores/constraints now works for ObjC ivars or struct fields.
This required more changes than I originally expected:

- ObjCIvarRegion implements "canPrintPretty" et al
- DereferenceChecker indicates the null pointer source is an ivar
- bugreporter::trackNullOrUndefValue() uses an alternate algorithm
  to compute the location region to track by scouring the ExplodedGraph.
  This allows us to get the actual MemRegion for variables, ivars,
  fields, etc.  We only hand construct a VarRegion for C++ references.
- ExplodedGraph no longer drops nodes for expressions that are marked
  'lvalue'.  This is to facilitate the logic in the previous bullet.
  This may lead to a slight increase in size in the ExplodedGraph,
  which I have not measured, but it is likely not to be a big deal.

I have validated each of the changed plist output.

Fixes <rdar://problem/12114812>

llvm-svn: 175988
2013-02-24 07:21:01 +00:00
Ted Kremenek e3cf171730 Add "KnownSVal" to represent SVals that cannot be UnknownSVal.
This provides a few sundry cleanups, and allows us to provide
a compile-time check for a case that was a runtime assertion.

llvm-svn: 175987
2013-02-24 07:20:53 +00:00
Argyrios Kyrtzidis fead64be9b [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the
full information about the macro (e.g if it was imported and where).

llvm-svn: 175978
2013-02-24 00:05:14 +00:00
Argyrios Kyrtzidis ecd77a98f0 Add comments for the MacroDirective & MacroInfo classes.
llvm-svn: 175977
2013-02-24 00:05:05 +00:00
Benjamin Kramer 2b0013e93b Shrink SmallPtrSet. It gets swapped a lot which copies the whole small part.
Testing shows that it's empty in >99% of the cases and I couldn't find a case
where it contained more than 2 elements.

llvm-svn: 175967
2013-02-23 16:56:22 +00:00
Benjamin Kramer 24ebf7c92c Add streamed versions of getQualifiedNameAsString.
Move the cold virtual method getNameForDiagnostic out of line.

llvm-svn: 175966
2013-02-23 13:53:57 +00:00
Enea Zaffanella aebdf81932 Remove data member MSAsmStmt::AsmLoc, wrongly hiding AsmStmt::AsmLoc.
llvm-svn: 175963
2013-02-23 12:27:19 +00:00
NAKAMURA Takumi 6fcb39e0f0 clang/AST/Decl.h: Add "raw_ostream.h" to appease msvc.
llvm-svn: 175952
2013-02-23 03:59:16 +00:00
David Blaikie 00be69ab5c Remove the CFGElement "Invalid" state.
Use Optional<CFG*> where invalid states were needed previously. In the one case
where that's not possible (beginAutomaticObjDtorsInsert) just use a dummy
CFGAutomaticObjDtor.

Thanks for the help from Jordan Rose & discussion/feedback from Ted Kremenek
and Doug Gregor.

Post commit code review feedback on r175796 by Ted Kremenek.

llvm-svn: 175938
2013-02-23 00:29:34 +00:00
Peter Collingbourne 47f9f2d1e6 Revert r175912, "Add support for coldcc to clang" at John's request.
llvm-svn: 175936
2013-02-23 00:06:18 +00:00
Eric Christopher f1545838d7 Propagate the split dwarf file information through into the backend
and through to the debug info in the module. In order to make the
testcase a bit more efficient allow the filename to go through
compilation for compile and not assemble jobs and turn off the
extract for cases where we don't create an object.

llvm-svn: 175935
2013-02-22 23:50:16 +00:00
Fariborz Jahanian f073871f7f objective-C arg: provide fixit support when
c++'s named cast need be replaced for bridge casting.
// rdar://12788838

llvm-svn: 175923
2013-02-22 22:02:53 +00:00
Eric Christopher d380400b17 Split out the command handling for split debug info, we're going
to want to propagate some information through the module into
the back end and so need to pass it through to codegen.

Also make the methods file static so we can use them in other places.

llvm-svn: 175916
2013-02-22 20:12:52 +00:00
Peter Collingbourne f32b3f2c55 Add support for coldcc to clang
llvm-svn: 175912
2013-02-22 19:24:35 +00:00
Argyrios Kyrtzidis 832de9fcf1 [preprocessing record] Have the MacroDefinitions map point to the MacroDefinition object instead
its index in the preprocessed entities vector.

This is because the order of the entities in the vector can change in some (uncommon) cases.

llvm-svn: 175907
2013-02-22 18:35:59 +00:00
Benjamin Kramer 2999b77f1d Replace some typically large vectors with SmallVector.
This may seem counter-intuitive but the POD-like optimization helps when the
vectors grow into multimegabyte buffers. SmallVector calls realloc which knows
how to twiddle virtual memory bits and avoids large copies.

llvm-svn: 175906
2013-02-22 18:29:39 +00:00
Michael Han 84324357b8 [Sema] Semantic analysis for empty-declaration and attribute-declaration.
Introduce a new AST Decl node "EmptyDecl" to model empty-declaration. Have attributes from attribute-declaration appertain
to the EmptyDecl node by creating the AST representations of these attributes and attach them to the EmptyDecl node so these
attributes can be sema checked just as attributes attached to "normal" declarations.

llvm-svn: 175900
2013-02-22 17:15:32 +00:00
Benjamin Kramer 9170e914fc Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList.
llvm-svn: 175894
2013-02-22 15:46:01 +00:00
Dmitri Gribenko acf2e786d2 Comment parsing: add CommentOptions to allow specifying custom comment block commands
Add an ability to specify custom documentation block comment commands via a new
class CommentOptions.  The intention is that this class will hold future
customizations for comment parsing, including defining documentation comments
with specific numbers of parameters, etc.

CommentOptions instance is a member of LangOptions.

CommentOptions is controlled by a new command-line parameter
-fcomment-block-commands=Foo,Bar,Baz.

llvm-svn: 175892
2013-02-22 14:21:27 +00:00
Richard Smith 44c247f0f0 Handle alignas(foo...) pack expansions.
llvm-svn: 175875
2013-02-22 08:32:16 +00:00
Richard Smith bc8caaf05f Implement C++11 [dcl.align]p6-p8, and C11 6.7.5/7. This had to be split out of
the normal attribute-merging path, because we can't merge alignment attributes
without knowing the complete set of alignment attributes which apply to a
particular declaration.

llvm-svn: 175861
2013-02-22 04:55:39 +00:00
Anna Zaks 04e7ff43a1 [analyzer] Place all inlining policy checks into one palce
Previously, we had the decisions about inlining spread out
over multiple functions.

In addition to the refactor, this commit ensures
that we will always inline BodyFarm functions as long as the Decl
is available. This fixes false positives due to those functions
not being inlined when no or minimal inlining is enabled such (as
shallow mode).

llvm-svn: 175857
2013-02-22 02:59:24 +00:00
Richard Smith b3a145293d Add -fbracket-depth=N, analogous to -ftemplate-depth= and -fconstexpr-depth=,
to control the check for the C 5.2.4.1 / C++ [implimits] restriction on nesting
levels for parentheses, brackets and braces.

Some code with heavy macro use exceeds the default limit of 256, but we don't
want to increase it generally to avoid stack overflow on stack-constrained
systems.

llvm-svn: 175855
2013-02-22 01:59:51 +00:00
Jordan Rose 5772f82d1e [analyzer] Make sure a materialized temporary matches its bindings.
This is a follow-up to r175830, which made sure a temporary object region
created for, say, a struct rvalue matched up with the initial bindings
being stored into it. This does the same for the case in which the AST
actually tells us that we need to create a temporary via a
MaterializeObjectExpr. I've unified the two code paths and moved a static
helper function onto ExprEngine.

This also caused a bit of test churn, causing us to go back to describing
temporary regions without a 'const' qualifier. This seems acceptable; it's
our behavior from a few months ago.

<rdar://problem/13265460> (part 2)

llvm-svn: 175854
2013-02-22 01:51:15 +00:00
Fariborz Jahanian ac2d082f58 objective-C arc: Diagnostic can not say to use bridge
casts with c++ named casts. Change notes to say use
bridge with c-style cast instead. // rdar://12788838

llvm-svn: 175850
2013-02-22 01:22:48 +00:00
Aaron Ballman 5902224022 Removing has_getDecl (added in r175532). It cause a build break for MSVC, and was not yet being used in the codebase. If we start using std::enable_if, we can look into resurrecting the idea in a more portable fashion.
llvm-svn: 175837
2013-02-22 00:15:31 +00:00
Eric Christopher d3cf33728b Grammar.
llvm-svn: 175833
2013-02-22 00:03:08 +00:00
John McCall 5f46c48514 Ignore visibility from enclosing template arguments
for explicit member specializations.

llvm-svn: 175827
2013-02-21 23:42:58 +00:00
David Blaikie 998cdc9eca Fix copy/paste to refer to the relevant type (ProgramPoint instead of TypeLoc).
Post commit review feedback on r175812 from Jordan Rose.

llvm-svn: 175825
2013-02-21 23:35:03 +00:00
Richard Smith 463abbb4a7 Fix typo 'with with' in diagnostic.
llvm-svn: 175823
2013-02-21 23:15:05 +00:00
Eric Christopher 248357f624 Remove the SplitDebug action and replace with a set of commands
in the compilation setup. Note that this doesn't currently
work for -no-integrated-as.

llvm-svn: 175813
2013-02-21 22:35:01 +00:00
David Blaikie 87396b9b08 Replace ProgramPoint llvm::cast support to be well-defined.
See r175462 for another example/more details.

llvm-svn: 175812
2013-02-21 22:23:56 +00:00
Ted Kremenek c6ebda167f Teach serialized diagnostics about notes without locations.
Along the way, improve a diagnostic for "previous declaration here" for implicit parameters.

Fixes <rdar://problem/13211384>.

llvm-svn: 175802
2013-02-21 21:40:44 +00:00
David Blaikie 2a01f5d426 Replace CFGElement llvm::cast support to be well-defined.
See r175462 for another example/more details.

llvm-svn: 175796
2013-02-21 20:58:29 +00:00
Jordan Rose cb8a1aca35 Preprocessor: preserve whitespace in -traditional-cpp mode.
Note that unlike GNU cpp we currently do not preserve whitespace in macros
(even in -traditional-cpp mode).

<rdar://problem/12897179>

llvm-svn: 175778
2013-02-21 18:53:19 +00:00
Chad Rosier 50f0c80341 [driver] Add a dump method for ArgList.
llvm-svn: 175777
2013-02-21 18:40:49 +00:00
David Blaikie 1c19139ae0 Correct spelling of 'enumerator'.
Post commit code review feedback to r175705 from Jordan Rose.

llvm-svn: 175725
2013-02-21 06:12:38 +00:00
David Blaikie 3a3c4e0f84 Avoid implicit conversions of Optional<T> to bool.
This is a precursor to making Optional<T>'s operator bool 'explicit' when
building Clang & LLVM as C++11.

llvm-svn: 175722
2013-02-21 06:05:05 +00:00
Jordan Rose 599f85ab85 [analyzer] Record whether a base object region represents a virtual base.
This allows MemRegion and MemRegionManager to avoid asking over and over
again whether an class is a virtual base or a non-virtual base.

Minor optimization/cleanup; no functionality change.

llvm-svn: 175716
2013-02-21 03:12:32 +00:00
David Blaikie 7a30dc53c5 Use None rather than Optional<T>() where possible.
llvm-svn: 175705
2013-02-21 01:47:18 +00:00
David Blaikie c4071fe13d Rename TypeLoc's isType to isKind
Matches changes made to SVal's similar functions based on Jordan Rose's review
feedback to r175594.

Also change isKind to take a reference rather than a non-null pointer, while I'm
at it. (& make TypeLoc::isKind private)

llvm-svn: 175704
2013-02-21 01:47:08 +00:00
David Blaikie f8db6917b3 Mark unimplemented function with LLVM_DELETED_FUNCTION
llvm-svn: 175695
2013-02-21 00:26:17 +00:00
David Blaikie 7d26e7ef51 Doxycomment SVal's getAs/castAs.
Also document TypeLoc's operations similarly, since it's a good idea.

Post-commit CR feedback from Anna Zaks regarding r175594.

llvm-svn: 175694
2013-02-21 00:26:14 +00:00
David Blaikie 05785d1622 Include llvm::Optional in clang/Basic/LLVM.h
Post-commit CR feedback from Jordan Rose regarding r175594.

llvm-svn: 175679
2013-02-20 22:23:23 +00:00
David Blaikie fa5eeba1dc Rename SVal::isType functions to SVal::isKind
Post-commit CR feedback from Jordan Rose regarding r175594.

llvm-svn: 175676
2013-02-20 22:22:59 +00:00
Richard Smith b19337fbe4 PR15311: Finish implementation of the suggested resolution of core issue 1488,
which allows grouping parens in an abstract-pack-declarator. This was already
mostly implemented, but missed some cases. Add an ExtWarn for use of this
extension until CWG ratifies it.

llvm-svn: 175660
2013-02-20 20:19:27 +00:00
Richard Smith 54ecd9863f Process and handle attributes on conditions and for loop variables. Process and
diagnose attributes on alias declarations, using directives, and attribute
declarations.

llvm-svn: 175649
2013-02-20 19:22:51 +00:00
David Blaikie 2fdacbc5b0 Replace SVal llvm::cast support to be well-defined.
See r175462 for another example/more details.

llvm-svn: 175594
2013-02-20 05:52:05 +00:00
John McCall d041a9bf2d Add a new 'type_visibility' attribute to allow users to
control the visibility of a type for the purposes of RTTI
and template argument restrictions independently of how
visibility propagates to its non-type member declarations.

Also fix r175326 to not ignore template argument visibility
on a template explicit instantiation when a member has
an explicit attribute but the instantiation does not.

The type_visibility work is rdar://11880378

llvm-svn: 175587
2013-02-20 01:54:26 +00:00
Argyrios Kyrtzidis 09c9e811de [preprocessor] Split the MacroInfo class into two separate concepts, MacroInfo class
for the data specific to a macro definition (e.g. what the tokens are), and
MacroDirective class which encapsulates the changes to the "macro namespace"
(e.g. the location where the macro name became active, the location where it was undefined, etc.)

(A MacroDirective always points to a MacroInfo object.)

Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but
splitting the concepts allows us to better model the effect of modules to the macro namespace
(also as a bonus it allows better modeling of push_macro/pop_macro #pragmas).
Modules can have their own macro history, separate from the local (current translation unit)
macro history; MacroDirectives will be used to model the macro history (changes to macro namespace).

For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created
to indicate that "FOO" became active at the import location. Module "A" itself will contain another
MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives
will point to the same MacroInfo object.

Introducing the separation of macro concepts is the first part towards better modeling of module macros.

llvm-svn: 175585
2013-02-20 00:54:57 +00:00
Richard Smith 4c96e99235 PR15300: Support C++11 attributes on base-specifiers. We don't support any such
attributes yet, so just issue the appropriate diagnostics. Also generalize the
fixit for attributes-in-the-wrong-place code and reuse it here, if attributes
are placed after the access-specifier or 'virtual' in a base specifier.

llvm-svn: 175575
2013-02-19 23:47:15 +00:00
Argyrios Kyrtzidis e441264019 [modules] Const'ify some functions of ModuleMap.
llvm-svn: 175552
2013-02-19 19:58:45 +00:00
Argyrios Kyrtzidis 8739f7b7f6 [modules] Refactor code from ASTReader::makeModuleVisible() into a new function,
Module::getExportedModules() so it can be reused.

llvm-svn: 175548
2013-02-19 19:34:40 +00:00
Edwin Vane 2c197e0939 Support in hasDeclaration for types with getDecl()
Using a new metafunction for detecting the presence of the member
'getDecl' in a type T, added support to hasDeclaration for any such type
T. This allows hasDecl() to be replaced and enables several other
subclasses of clang::Type to use hasDeclaration.

Updated unittests and LibASTMatchersReference.html.

Reviewers: klimek
llvm-svn: 175532
2013-02-19 17:14:34 +00:00
John McCall b4a99d3194 Add support for -fvisibility-ms-compat.
We treat this as an alternative to -fvisibility=<?>
which changes the default value visibility to "hidden"
and the default type visibility to "default".

Expose a -cc1 option for changing the default type
visibility, repurposing -fvisibility as the default
value visibility option (also setting type visibility
from it in the absence of a specific option).

rdar://13079314

llvm-svn: 175480
2013-02-19 01:57:35 +00:00
David Blaikie 7cba50dfd4 Use LLVM_DELETED_FUNCTION rather than '// do not implement' comments.
Also removes some redundant DNI comments on function declarations already
using the macro.

llvm-svn: 175465
2013-02-18 23:11:09 +00:00
David Blaikie 6adc78e0df Replace TypeLoc llvm::cast support to be well-defined.
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined
behavior by casting pointers/references to TypeLoc objects to derived types
and then using the derived copy constructors (or even returning pointers to
derived types that actually point to the original TypeLoc object).

Some context is in this thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html
Though it's spread over a few months which can be hard to read in the mail
archive.

llvm-svn: 175462
2013-02-18 22:06:02 +00:00
David Blaikie b61d087d40 Clean up last use of dyn_cast on TypeLoc in ASTMatchers
llvm-svn: 175454
2013-02-18 19:04:16 +00:00
Argyrios Kyrtzidis 774c2479ad Add include guards for CommentVisitor.h
llvm-svn: 175451
2013-02-18 18:31:16 +00:00
Douglas Gregor 6168bd2323 Ensure that the identifier chains have the most recent declaration after module deserialization.
This commit introduces a set of related changes to ensure that the
declaration that shows up in the identifier chain after deserializing
declarations with a given identifier is, in fact, the most recent
declaration. The primary change involves waiting until after we
deserialize and wire up redeclaration chains before updating the
identifier chains. There is a minor optimization in here to avoid
recursively deserializing names as part of looking to see whether
top-level declarations for a given name exist.

A related change that became suddenly more urgent is to property
record a merged declaration when an entity first declared in the
current translation unit is later deserialized from a module (that had
not been loaded at the time of the original declaration). Since we key
off the canonical declaration (which is parsed, not from an AST file)
for emitted redeclarations, we simply record this as a merged
declaration during AST writing and let the readers merge them.

Re-fixes <rdar://problem/13189985>, presumably for good this time.

llvm-svn: 175447
2013-02-18 15:53:43 +00:00
James Dennett e8ee9e53f7 Documentation: use \brief and don't duplicate the name of the declared entity
at the start of the doc comment.

llvm-svn: 175391
2013-02-17 08:24:19 +00:00
James Dennett 5d0da59b3d Documentation cleanup: fix a typo ("////" for "///") and suppress Doxygen's
automatic link generation for "file:", as it's not used as a URL here.

llvm-svn: 175390
2013-02-17 08:19:35 +00:00
Dmitri Gribenko 20b16ace16 Use trailing documentation comments properly
Patch by Alexander Zinenko.

llvm-svn: 175376
2013-02-16 22:21:38 +00:00
James Dennett 49049ee8c7 Documentation cleanup: make a \brief be brief, and fix a bad use of \see.
llvm-svn: 175340
2013-02-16 08:16:47 +00:00
James Dennett bd59295fb7 Documentation cleanup: use \brief, and don't repeat the identifier being
declared.

llvm-svn: 175339
2013-02-16 07:45:22 +00:00
Jordan Rose 9ed04aa7ac libAnalysis: Add a case for TypeAliasDecl in CFGRecStmtDeclVisitor.
Neither of the current clients of CFGRecStmtDeclVisitor are doing
anything with typedefs, so I assume type aliases (C++11 "using")
can be safely ignored. This was causing assertion failures in
the analyzer.

<rdar://problem/13228440>

llvm-svn: 175335
2013-02-16 01:33:16 +00:00
Dmitri Gribenko cea5ad4c0d Remove unused forward declarations
clang/AST/Decl.h is included to see the TypeSourceInfo definition anyway.

llvm-svn: 175332
2013-02-16 01:06:07 +00:00
Argyrios Kyrtzidis 83a6e3bfab [PCH] Deserializing the DeclContext of a template parameter is not safe
until recursive loading is finished.

Otherwise we may end up with a template trying to deserialize a template
parameter that is in the process of getting loaded.

rdar://13135282

llvm-svn: 175329
2013-02-16 00:48:59 +00:00
Dmitri Gribenko 0062ba6494 Remove unused forward declarations
llvm-svn: 175328
2013-02-16 00:41:34 +00:00
John McCall df25c43599 Rework the visibility computation algorithm in preparation
for distinguishing type vs. value visibility.

The changes to the visibility of explicit specializations
are intentional.  The change to the "ugly" test case is
a consequence of a sensible implementation, and I am happy
to argue that this is better behavior.  Other changes may
or may not be intended;  it is quite difficult to divine
intent from some of the code I altered.

I've left behind a comment which I hope explains the
philosophy behind visibility computation.

llvm-svn: 175326
2013-02-16 00:17:33 +00:00
Dmitri Gribenko 0035372bb7 libclang: add clang_getTypeSpelling(CXType CT)
Adds a function clang_getTypeSpelling(CXType CT) that returns
a CXString containing the underlying type.

Patch by Ben Gertzfield.

llvm-svn: 175299
2013-02-15 21:15:49 +00:00
Fariborz Jahanian d4c1a2063c objective-C: Fixes a compiler crash when encoding
an ivar of type pointer to a typedef'ed object.
// rdar://13190095

llvm-svn: 175298
2013-02-15 21:14:50 +00:00
Argyrios Kyrtzidis e6e422b1ee When a statement is dropped from the AST because it was invalid, make sure
we don't do the scope checks otherwise we are going to hit assertion checks
since a label may not have been actually added.

llvm-svn: 175281
2013-02-15 18:34:13 +00:00
Jordan Rose 88bb563c43 Re-apply "[analyzer] Model trivial copy/move ctors with an aggregate bind."
...after a host of optimizations related to the use of LazyCompoundVals
(our implementation of aggregate binds).

Originally applied in r173951.
Reverted in r174069 because it was causing hangs.
Re-applied in r174212.
Reverted in r174265 because it was /still/ causing hangs.

If this needs to be reverted again it will be punted to far in the future.

llvm-svn: 175234
2013-02-15 00:32:15 +00:00
Fariborz Jahanian aedaaa4f35 objective-C: synthesize properties in order of their
declarations to synthesize their ivars in similar
determinstic order so they are laid out in
a determinstic order. // rdar://13192366

llvm-svn: 175214
2013-02-14 22:33:34 +00:00
Fariborz Jahanian a934a022af objective-C: When implementing custom accessor method for
a property, the -Wdirect-ivar-access should not warn when 
accessing the property's synthesized instance variable.
// rdar://13142820

llvm-svn: 175195
2013-02-14 19:07:19 +00:00
Dmitri Gribenko 6cfb1537b6 Remove a const_cast by propagating constness to called functions
llvm-svn: 175161
2013-02-14 13:53:30 +00:00
Dmitri Gribenko 81f2575692 Remove const_casts by making spec_begin()/spec_end() const
llvm-svn: 175159
2013-02-14 13:20:36 +00:00
Bill Wendling c86a2f39a9 Pass the target options through to code generation.
The code generation stuff is going to set attributes on the functions it
generates. To do that it needs the target options. Pass them through.

llvm-svn: 175141
2013-02-14 08:09:20 +00:00
Rafael Espindola 5bda63f16b merge hasCLanguageLinkage and isExternC. Keep the shorter name.
I added hasCLanguageLinkage while fixing some language linkage bugs some
time ago so that I wouldn't have to check all users of isExternC. It turned
out to be a much longer detour than expected, but this patch finally
merges the two again. The isExternC function now implements just the
standard notion of having C language linkage.

llvm-svn: 175119
2013-02-14 01:47:04 +00:00
Rafael Espindola f4187658fa Add a getLanguageLinkage method to VarDecls and FunctionDecls. Use it to fix
some cases where functions with no language linkage were being treated as having
C language linkage. In particular, don't warn in

extern "C" {
  static NonPod foo();
}

Since getLanguageLinkage checks the language linkage, the linkage computation
cannot use the language linkage. Break the loop by checking just the context
in the linkage computation.

llvm-svn: 175117
2013-02-14 01:18:37 +00:00
Daniel Jasper b9caeacd02 Allow breaking after the return type in function declarations.
This has so far been disabled for Google style, but should be done
before breaking at nested name specifiers or in template parameters.

Before (in Google style):
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa<
    T>::aaaaaaa() {}

After:
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaa() {}

llvm-svn: 175074
2013-02-13 20:33:44 +00:00
Edwin Vane e9dd3608ea Adding more overloads for allOf matcher
Adding overloads of allOf accepting 4 and 5 arguments.
    
Reviewer: klimek

llvm-svn: 174967
2013-02-12 13:55:40 +00:00
Richard Smith a00399c949 Remove an assert which triggers when a decl context in a module hits the 'has
lexical storage but not visible storage' case in C++. It's unclear whether we
even need the special-case handling for C++, since it seems to be working
around our not serializing a lookup table for the TU in C. But in any case,
the assertion is incorrect.

llvm-svn: 174931
2013-02-12 02:32:35 +00:00
John McCall 6ced97aaae Diagnose loads of 'half' l-values in OpenCL.
Patch by Joey Gouly!

llvm-svn: 174928
2013-02-12 01:29:43 +00:00
Richard Smith 86a12015ee Don't bother reconciling external visible decls against our current set of
declarations if we didn't have a lookup map when the external decls were added.

llvm-svn: 174906
2013-02-11 22:02:16 +00:00
Manuel Klimek ca846ae622 Do not use VariadicDynCastAllOfMatcher where VariadicAllOfMatcher works.
llvm-svn: 174862
2013-02-11 07:45:01 +00:00
Fariborz Jahanian 234c00d6d0 objective-C: Fixes a bogus warning due to not setting
the "nonatomic" attribute in property redeclaration
in class extension. Also, improved on diagnostics in
this area while at it. // rdar://13156292

llvm-svn: 174821
2013-02-10 00:16:04 +00:00
Dmitri Gribenko f340008eab Remove unreachable statement
llvm-svn: 174811
2013-02-09 15:24:28 +00:00
Jordan Rose 4938f276a5 Remove some stray uses of <ctype.h> functions.
These are causing assertions on some MSVC builds.

llvm-svn: 174805
2013-02-09 10:09:43 +00:00
Ted Kremenek 7ee25676a5 QoI: -Wreadonly-iboutlet-property should have the warning's location on the property.
There's no need to refer to the @implementation at all.

Fixes <rdar://problem/13186515>

llvm-svn: 174802
2013-02-09 07:13:16 +00:00
Douglas Gregor 7dab26b87c Ensure that type definitions present in just-loaded modules are
visible.

The basic problem here is that a given translation unit can use
forward declarations to form pointers to a given type, say,

  class X;
  X *x;

and then import a module that includes a definition of X:

  import XDef;

We will then fail when attempting to access a member of X, e.g., 

  x->method()

because the AST reader did not know to look for a default of a class
named X within the new module.

This implementation is a bit of a C-centric hack, because the only
definitions that can have this property are enums, structs, unions,
Objective-C classes, and Objective-C protocols, and all of those are
either visible at the top-level or can't be defined later. Hence, we
can use the out-of-date-ness of the name and the identifier-update
mechanism to force the update.

In C++, we will not be so lucky, and will need a more advanced
solution, because the definitions could be in namespaces defined in
two different modules, e.g.,

  // module 1
  namespace N { struct X; }

  // module 2
  namespace N { struct X { /* ... */ }; }

One possible implementation here is for C++ to extend the information
associated with each identifier table to include the declaration IDs
of any definitions associated with that name, regardless of
context. We would have to eagerly load those definitions.

llvm-svn: 174794
2013-02-09 01:35:03 +00:00
Jordan Rose 58c61e006f Properly validate UCNs for C99 and C++03 (both more restrictive than C(++)11).
Add warnings under -Wc++11-compat, -Wc++98-compat, and -Wc99-compat when a
particular UCN is incompatible with a different standard, and -Wunicode when
a UCN refers to a surrogate character in C++03.

llvm-svn: 174788
2013-02-09 01:10:25 +00:00
Anna Zaks 0d8779cb79 [analyzer] Move DefaultBool so that all checkers can share it.
llvm-svn: 174782
2013-02-08 23:55:50 +00:00
Jordan Rose a7d03840e6 Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.

llvm-svn: 174768
2013-02-08 22:30:41 +00:00
Jordan Rose a2100d755a Pull Lexer's CharInfo table out for general use throughout Clang.
Rewriting the same predicates over and over again is bad for code size and
code maintainence. Using the functions in <ctype.h> is generally unsafe
unless they are specified to be locale-independent (i.e. only isdigit and
isxdigit).

The next commit will try to clean up uses of <ctype.h> functions within Clang.

llvm-svn: 174765
2013-02-08 22:30:22 +00:00
Fariborz Jahanian e4c7e855f1 objective-C modern translator. Generate #line
info in the translated code under -g only.
// rdar://13138170

llvm-svn: 174684
2013-02-08 00:27:34 +00:00
Douglas Gregor f5f9452808 Teach subframework header lookup to suggest modules <rdar://problem/13176200>.
llvm-svn: 174683
2013-02-08 00:10:48 +00:00
Anna Zaks acdc13cb00 [analyzer] Add pointer escape type param to checkPointerEscape callback
The checkPointerEscape callback previously did not specify how a
pointer escaped. This change includes an enum which describes the
different ways a pointer may escape. This enum is passed to the
checkPointerEscape callback when a pointer escapes. If the escape
is due to a function call, the call is passed. This changes
previous behavior where the call is passed as NULL if the escape
was due to indirectly invalidating the region the pointer referenced.

A patch by Branden Archer!

llvm-svn: 174677
2013-02-07 23:05:43 +00:00
Douglas Gregor 35b04d6fd2 Rename -fmodule-cache-path <blah> to -fmodules-cache-path=<blah> for consistency.
llvm-svn: 174645
2013-02-07 19:01:24 +00:00
Guy Benyei 259f9f4531 Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builtin functions.
llvm-svn: 174630
2013-02-07 16:05:33 +00:00
Manuel Klimek bee085762b Implements equalsNode for Decl and Stmt.
This is a powerful tool when doing iterative refined matches,
where another match is started inside the match callback of the first
one; this allows for example to find out whether the node was in
the condition or body of its parent if-statement.

llvm-svn: 174605
2013-02-07 12:42:10 +00:00
Guy Benyei 610541989a Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
2013-02-07 10:55:47 +00:00
Richard Smith 645d755d3e Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).

1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.

2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.

llvm-svn: 174577
2013-02-07 03:37:08 +00:00
Richard Smith 9ce12e36ab Simplify FindExternalVisibleDeclsByName by making it return a bool indicating
if it found any decls, rather than returning a list of found decls. This
removes a returning-ArrayRef-to-deleted-storage bug from
MultiplexExternalSemaSource (in code not exercised by any of the clang
binaries), reduces the work required in the found-no-decls case with PCH, and
importantly removes the need for DeclContext::lookup to be reentrant.

No functionality change intended!

llvm-svn: 174576
2013-02-07 03:30:24 +00:00
Douglas Gregor 5dc3899ca4 Introduce -fmodules-ignore-macro=NNN to ignore a macro when building/loading modules.
The use of this flag enables a modules optimization where a given set
of macros can be labeled as "ignored" by the modules
system. Definitions of those macros will be completely ignored when
building the module hash and will be stripped when actually building
modules. The overall effect is that this flag can be used to
drastically reduce the number of

Eventually, we'll want modules to tell us what set of macros they
respond to (the "configuration macros"), and anything not in that set
will be excluded. However, that requires a lot of per-module
information that must be accurate, whereas this option can be used
more readily.

Fixes the rest of <rdar://problem/13165109>.

llvm-svn: 174560
2013-02-07 00:21:12 +00:00
Douglas Gregor 8a114ab557 Detect when we end up trying to load conflicting module files.
This can happen when one abuses precompiled headers by passing more -D
options when using a precompiled hedaer than when it was built. This
is intentionally permitted by precompiled headers (and is exploited by
some build environments), but causes problems for modules.

First part of <rdar://problem/13165109>, detecting when something when
horribly wrong.

llvm-svn: 174554
2013-02-06 22:40:31 +00:00
Manuel Klimek 4feac28e0e Cleanup of ASTMatcher macros and adding support for overloaded matchers.
This is in preparation for adding other overloaded matchers. This change
alone is a net win in LOC.
I went through all matchers and looked whether we could now encode them
as macro, or simplify them with the matcher atoms that were not
available before.

llvm-svn: 174540
2013-02-06 20:36:22 +00:00