Richard Smith [Thu, 15 Mar 2012 00:41:48 +0000 (00:41 +0000)]
Minor optimization to constant evaluation: don't bother computing expr source
locations for diagnostics we're not going to emit, and don't track the subobject
designator outside C++11 (since we're not going to use it anyway).
This seems to give about a 0.5% speedup on 403.gcc/combine.c, but the results
were sufficiently noisy that I can't reject the null hypothesis.
Chad Rosier [Wed, 14 Mar 2012 23:32:11 +0000 (23:32 +0000)]
[frontend] Add support for disabling the "inline" keyword using
-fno-inline-functions.
This behaves much like -fno-inline in gcc, but based on a discussion with
Daniel it was decided that -fno-inline-functions should subsume -fno-inline.
Please speak up if you object. The -fno-inline flag remains ignored.
Final part of rdar://10972766
Richard Smith [Wed, 14 Mar 2012 23:13:10 +0000 (23:13 +0000)]
Instantiating a class template should not instantiate the definition of any
scoped enumeration members. Later uses of an enumeration temploid as a nested
name specifier should cause its instantiation. Plus some groundwork for
explicit specialization of member enumerations of class templates.
David Blaikie [Wed, 14 Mar 2012 22:28:22 +0000 (22:28 +0000)]
Provide -Wnull-conversion separately from -Wconversion.
Like GCC, provide a NULL conversion to non-pointer conversion as a separate
flag, on by default. GCC's flag is "conversion-null" which we provide for
cross compatibility, but in the interests of consistency (with
-Wint-conversion, -Wbool-conversion, etc) the canonical Clang flag is called
-Wnull-conversion.
Patch by Lubos Lunak.
Review feedback by myself, Chandler Carruth, and Chad Rosier.
Daniel Dunbar [Wed, 14 Mar 2012 09:49:36 +0000 (09:49 +0000)]
[Basic] Change DiagnosticBuilder to use a separate status variable to track whether the builder is active.
- This may seem superflous, but actually this allows the optimizer to more
easily eliminate the isActive() checks needed by the SemaDiagnosticBuilder
and DiagnosticBuilder dtors. And by more easily, I mean the current LLVM is
actually able to do one and not the other. :)
Daniel Dunbar [Wed, 14 Mar 2012 09:49:32 +0000 (09:49 +0000)]
[Sema] Fix SemaDiagnosticBuilder to be inline.
- As with DiagnosticBuilder, it is very important that SemaDiagnosticBuilder be
completely inline to ensure that the compiler can rip it apart and sink it to
registers.
This is good for another 30k reduction in code size.
David Blaikie [Tue, 13 Mar 2012 23:33:06 +0000 (23:33 +0000)]
Add a test case for PR8385.
"struct{template struct{" would fail an assertion.
This assertion failure seems to have gone away somewhere along the line so
here's a test to make sure we don't regress. We still accept some very weird
explicit template 'instantiations' ("template int;", anyone) but at least we're
not asserting/crashing here.
Daniel Dunbar [Tue, 13 Mar 2012 21:02:14 +0000 (21:02 +0000)]
[Basic] Fix up DiagnosticBuilder::{FlushCounts,Emit} to be inline.
- This is much more important than it appears at first glance...
The intended design of DiagnosticBuilder was that it never escape and that all
its members would get lowered to registers by the compiler. By fixing Emit here,
the compiler can completely eliminate the DiagnosticBuilder object and never
need to push those registers back into it.
Unfortunately, Sema has broken DiagnosticBuilder in other ways (by introducing
SemaDiagnosticBuilder), so we don't get the fill impact of this, but it is still
good for 30k reduction in code size. I'll work on fixing the
SemaDiagnosticBuilder problems next.
Chad Rosier [Tue, 13 Mar 2012 20:09:56 +0000 (20:09 +0000)]
[driver] Parse diagnostic args in the driver.
Previously, only diagnostics thrown by the cc1 process were
actually honoring the diagnostic options given on the command line,
like -Werror.
Reuse the existing code in Frontend currently used for cc1,
adjusting it to not interpret -Wl, linker flags as warnings.
Also fix a faulty test exposed by this change.
It wasn't actually testing anything, and was giving this warning:
clang-3: warning: argument unused during compilation: '-verify'
Which -Werror didn't turn into an error because it was output
by the driver, not the cc1 process, and diagnostic options
weren't parsed by the driver. And you couldn't see the warning
when running the test suite.
Fixes PR12181.
Patch by Dylan Noblesmith <nobled@dreamwidth.org>.
Anna Zaks [Tue, 13 Mar 2012 19:32:19 +0000 (19:32 +0000)]
[analyzer] Change the order in which we analyze the functions under
inlining to be the reverse of their declaration.
This optimizes running time under inlining up to 20% since we do not
re-analyze the utility functions which are usually defined first in the
translation unit if they have already been analyzed while inlined into
the root functions.
Anna Zaks [Tue, 13 Mar 2012 19:32:13 +0000 (19:32 +0000)]
[analyzer] Use BFS over call graph when analysing functions.
BFS should give slightly better performance. Ex: Suppose, we have two
roots R1 and R2. A callee function C is reachable through both. However,
C is not inlined when analyzing R1 due to inline stack depth limit. With
DFS, C will be analyzed as top level even though it would be analyzed as
inlined through R2. On the other hand, BFS could avoid analyzing C as
top level.
Daniel Dunbar [Tue, 13 Mar 2012 18:30:38 +0000 (18:30 +0000)]
[Basic] Fix ~Diagnostic() to not call Emit() when there is no diag obj (most
commonly when the diag has been copied).
- This eliminates a completely spurious call to Emit() which was in
Sema::Diag(). Sob.
Daniel Dunbar [Tue, 13 Mar 2012 18:21:17 +0000 (18:21 +0000)]
[Basic] Stop using a SmallVector<> for Diagnostic. This drops Clang binary size
by ~%.3/~100k in my build -- simply by eliminating the horrible code bloat coming
from the .clear() of the SmallVector<FixItHint>, which does a std::~string, etc.
- My understanding is we don't ever emit arbitrary numbers of fixits, so I just
moved us to using a statically sized array like we do for arguments and
ranges.
Richard Smith [Tue, 13 Mar 2012 07:21:50 +0000 (07:21 +0000)]
Implement [temp.param]p5: the top-level cv-qualifiers on a non-type template
parameter's declaration are ignored when determining the parameter's type.
Richard Smith [Tue, 13 Mar 2012 03:12:56 +0000 (03:12 +0000)]
Fix PR10447: lazily building name lookup tables for DeclContexts was broken.
The deferred lookup table building step couldn't accurately tell which Decls
should be included in the lookup table, and consequently built different tables
in some cases.
Fix this by removing lazy building of DeclContext name lookup tables. In
practice, the laziness was frequently not worthwhile in C++, because we
performed lookup into most DeclContexts. In C, it had a bit more value,
since there is no qualified lookup.
In the place of lazy lookup table building, we simply don't build lookup tables
for function DeclContexts at all. Such name lookup tables are not useful, since
they don't capture the scoping information required to correctly perform name
lookup in a function scope.
The resulting performance delta is within the noise on my testing, but appears
to be a very slight win for C++ and a very slight loss for C. The C performance
can probably be recovered (if it is a measurable problem) by avoiding building
the lookup table for the translation unit.
[Sema] Prefer to use ObjCInterfaceDecl's protocol_begin()/protocol_end() iterators instead of
ObjCInterfaceDecl::getReferencedProtocols(), because the iterators are safe to use
even if the caller did not check that the interface is a definition.
John McCall [Tue, 13 Mar 2012 00:37:01 +0000 (00:37 +0000)]
Alternate fix to PR12248: put Sema in charge of special-casing
the diagnostic for assigning to a copied block capture. This has
the pleasant side-effect of letting us special-case the diagnostic
for assigning to a copied lambda capture as well, without introducing
a new non-modifiable enumerator for it.
Bill Wendling [Mon, 12 Mar 2012 21:22:35 +0000 (21:22 +0000)]
Have clang pay attention to the LIBRARY_PATH environment variable.
The LIBRARY_PATH environment variable should be honored by clang. Have the
driver pass the directories to the linker.
<rdar://problem/9743567> and PR10296.
Douglas Gregor [Mon, 12 Mar 2012 21:09:16 +0000 (21:09 +0000)]
C++11 [temp.deduct.call]p6 tweak: when given a set of overlaoded
functions that includes an explicit template argument list, perform
an inner deduction against each of the function templates in that list
and, if successful, use the result of that deduction for the outer
template argument deduction. Fixes PR11713.
[Sema] -Add an invalid objc category to the DeclContext so that it can be
serialized
-Don't add methods of invalid objc containers to the global method pool.
This protects us from trying to serialize a method whose container was not
serialized.
Richard Smith [Mon, 12 Mar 2012 07:56:15 +0000 (07:56 +0000)]
Fix parsing of type-specifier-seq's. Types are syntactically allowed to be
defined here, but not semantically, so
new struct S {};
is always ill-formed, even if there is a struct S in scope.
We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being
under-loved (due to it only being used in a few places) so merge it into
ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this
required improving ParseDeclarationSpecifiers' diagnostics in some cases. This
also required teaching ParseSpecifierQualifierList about constexpr... which
incidentally fixes an issue where we'd allow the constexpr specifier in other
bad places.
NAKAMURA Takumi [Sun, 11 Mar 2012 08:04:40 +0000 (08:04 +0000)]
Update library dependencies to add clangEdit on c-index-test and c-arcmt-test.
To link with -static -lclang, linker tries to seek not libclang.so, clang.dll nor libclang.dll.a, but libclang.a. USEDLIBS should have correct dependencies for -static.
(In contrast, USEDLIBS=libclang.so might be enough w/o -static)
FYI, cygwin build (in buildbot) is using -static, due to avoiding weirdness of extremely slower startup lag of clang.exe.
llvm::SwitchInst
Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default.
Added some notes relative to case iterators.
Douglas Gregor [Sun, 11 Mar 2012 03:29:50 +0000 (03:29 +0000)]
When template argument deduction is ignoring qualifiers, perform deep
structural comparison of non-dependent types. Otherwise, we end up
rejecting cases where the non-dependent types don't match due to
qualifiers in, e.g., a pointee type. Fixes PR12132.
Douglas Gregor [Sat, 10 Mar 2012 23:52:41 +0000 (23:52 +0000)]
When determining whether an identifier followed by a '<' in a member
access expression is the start of a template-id, ignore function
templates found in the context of the entire postfix-expression. Fixes
PR11856.
Aaron Ballman [Sat, 10 Mar 2012 22:21:14 +0000 (22:21 +0000)]
No longer defining GNUC mode when compiling for Microsoft compatibility. This allows people's cross-platform compiler-specific macros to work properly.