Commit Graph

2354 Commits

Author SHA1 Message Date
Matt Beaumont-Gay 69e227b7b1 Suppress -Wunused-variable warning in -Asserts build
llvm-svn: 155011
2012-04-18 17:25:16 +00:00
Seth Cantrell 01d61b0ae4 fix display of source lines with null characters
llvm-svn: 154981
2012-04-18 02:44:48 +00:00
Seth Cantrell 99e2fa87f8 Nicer display of unprintable source, and fix caret display for non-ascii text
Unprintable source in diagnostics is transformed to a printable form and then
displayed with reversed colors if possible. Unprintable characters are
displayed as <U+NNNN> while bytes that do not represent valid characters are
shown as <XX>.

Column adjustments to diagnostic carets, highlighted ranges, and fixups are
made both for characters escaped as above and for characters which are
printable but take up more than a single column.

llvm-svn: 154980
2012-04-18 02:44:46 +00:00
Seth Cantrell 14dc87fccc Revert "Nicer display of unprintable source, and fix caret display for non-ascii text"
This reverts commit e9a3b76ba589a8a884e978273beaed0d97cf9861.

Revert "fix display of source lines with null characters"

This reverts commit 70712b276e40bbe11e5063dfc7e82ce3209929cd.

llvm-svn: 154950
2012-04-17 20:59:59 +00:00
Seth Cantrell f504f99c7d fix display of source lines with null characters
llvm-svn: 154947
2012-04-17 20:06:06 +00:00
Seth Cantrell fae205811e Nicer display of unprintable source, and fix caret display for non-ascii text
Unprintable source in diagnostics is transformed to a printable form and then
displayed with reversed colors if possible. Unprintable characters are
displayed as <U+NNNN> while bytes that do not represent valid characters are
shown as <XX>.

Column adjustments to diagnostic carets, highlighted ranges, and fixups are
made both for characters escaped as above and for characters which are
printable but take up more than a single column.

llvm-svn: 154946
2012-04-17 20:06:03 +00:00
Fariborz Jahanian 29898f4565 objective-c modern translator: buildit objc bool
type for rewriter project will be BoolTy.
// rdar://11231426. 

llvm-svn: 154861
2012-04-16 21:03:30 +00:00
Benjamin Kramer ffe7c7f4b2 ASTUnit: Don't clone the new DiagnosticConsumer, causing it to get leaked.
llvm-svn: 154739
2012-04-14 09:11:56 +00:00
Douglas Gregor adfb842fc1 Remove the -cc1-level option "-pubnames-dump". Such things should stay
out of the tree and use the tooling infrastructure.

llvm-svn: 154668
2012-04-13 16:03:00 +00:00
Richard Smith 01ba47d7b6 Implement the missing pieces needed to support libstdc++4.7's <atomic>:
__atomic_test_and_set, __atomic_clear, plus a pile of undocumented __GCC_*
predefined macros.

Implement library fallback for __atomic_is_lock_free and
__c11_atomic_is_lock_free, and implement __atomic_always_lock_free.

Contrary to their documentation, GCC's __atomic_fetch_add family don't
multiply the operand by sizeof(T) when operating on a pointer type.
libstdc++ relies on this quirk. Remove this handling for all but the
__c11_atomic_fetch_add and __c11_atomic_fetch_sub builtins.

Contrary to their documentation, __atomic_test_and_set and __atomic_clear
take a first argument of type 'volatile void *', not 'void *' or 'bool *',
and __atomic_is_lock_free and __atomic_always_lock_free have an argument
of type 'const volatile void *', not 'void *'.

With this change, libstdc++4.7's <atomic> passes libc++'s atomic test suite,
except for a couple of libstdc++ bugs and some cases where libc++'s test
suite tests for properties which implementations have latitude to vary.

llvm-svn: 154640
2012-04-13 00:45:38 +00:00
Erik Verbruggen 2fca3c2c87 Changed all direct calls to CompletionConsumer.reset(..) to go call
CompilerInstance::setCodeCompletionConsumer instead, in order to change
the SkipFunctionBodies flag accordingly. Also fixed
setCodeCompletionConsumer to take a reset() to null into account.

llvm-svn: 154585
2012-04-12 10:31:12 +00:00
Erik Verbruggen 6e92251f9b Added a flag to the parser to skip method bodies.
llvm-svn: 154584
2012-04-12 10:11:59 +00:00
Argyrios Kyrtzidis ac1cc934b3 [libclang] If displayDiagnostics is set (when calling clang_createIndex), make sure to
output the errors that occurred even if we did not get an AST (e.g. because the
PCH failed to load).

Also honor displayDiagnostics in clang_indexSourceFile().

rdar://11203489

llvm-svn: 154472
2012-04-11 02:11:16 +00:00
Argyrios Kyrtzidis 9d7c0fef65 [code-complete] Introduce CodeCompletionTUInfo which will be used for caching
code-completion related strings specific to a translation unit (ASTContext and related data)

CodeCompletionAllocator does such limited caching, by caching the name assigned
to a DeclContext*, but that is not the appropriate place since that object has
a lifetime that can extend beyond that of an ASTContext.

Introduce CodeCompletionTUInfo which will be always tied to a translation unit
to do this kind of caching and move the caching of CodeCompletionAllocator into this
object, and propagate it to all the places where it will be needed.

The plan is to extend the caching where appropriate, using CodeCompletionTUInfo,
to avoid re-calculating code-completion strings.

Part of rdar://10796159.

llvm-svn: 154408
2012-04-10 17:23:48 +00:00
David Chisnall 58464d0fe1 Revert r154321, pending more discussion.
llvm-svn: 154327
2012-04-09 17:25:11 +00:00
David Chisnall 4ec2af2fab Add -fobjc-trace to emit a call before and after each Objective-C message send
for hooking in code flow visualisation applications.  

llvm-svn: 154321
2012-04-09 15:42:15 +00:00
Chandler Carruth c0c0455f55 Teach Clang about PIE compilations. This is the first step of PR12380.
First, this patch cleans up the parsing of the PIC and PIE family of
options in the driver. The existing logic failed to claim arguments all
over the place resulting in kludges that marked the options as unused.
Instead actually walk all of the arguments and claim them properly.

We now treat -f{,no-}{pic,PIC,pie,PIE} as a single set, accepting the
last one on the commandline. Previously there were lots of ordering bugs
that could creep in due to the nature of the parsing. Let me know if
folks would like weird things such as "-fPIE -fno-pic" to turn on PIE,
but disable full PIC. This doesn't make any sense to me, but we could in
theory support it.

Options that seem to have intentional "trump" status (-static, -mkernel,
etc) continue to do so and are commented as such.

Next, a -pie-level flag is threaded into the frontend, rigged to
a language option, and handled preprocessor, setting up the appropriate
defines. We'll now have the correct defines when compiling with -fpie.

The one place outside of the preprocessor that was inspecting the PIC
level (as opposed to the relocation model, which is set and handled
separately, yay!) is in the GNU ObjC runtime. I changed it to exactly
preserve existing behavior. If folks want to change its behavior in the
face of PIE, they can do that in a separate patch.

Essentially the only functionality changed here is the preprocessor
defines and bug-fixes to the argument management.

Tests have been updated and extended to test all of this a bit more
thoroughly.

llvm-svn: 154291
2012-04-08 16:40:35 +00:00
Anna Zaks 72eee39df7 [analyzer] Enable retry exhausted without inlining by default.
llvm-svn: 153591
2012-03-28 19:59:16 +00:00
Chandler Carruth 8b4140d712 Move the emission of strict enum range metadata behind a flag (the same
flag as GCC uses: -fstrict-enums). There is a *lot* of code making
unwarranted assumptions about the underlying type of enums, and it
doesn't seem entirely reasonable to eagerly break all of it.

Much more importantly, the current state of affairs is *very* good at
optimizing based upon this information, which causes failures that are
very distant from the actual enum. Before we push for enabling this by
default, I think we need to implement -fcatch-undefined-behavior support
for instrumenting and trapping whenever we store or load a value outside
of the range. That way we can track down the misbehaving code very
quickly.

I discussed this with Rafael, and currently the only important cases he
is aware of are the bool range-based optimizations which are staying
hard enabled. We've not seen any issue with those either, and they are
much more important for performance.

llvm-svn: 153550
2012-03-27 23:58:37 +00:00
Anna Zaks 5b3939fae6 [analyzer] Add an option to re-analyze a dead-end path without inlining.
The analyzer gives up path exploration under certain conditions. For
example, when the same basic block has been visited more than 4 times.
With inlining turned on, this could lead to decrease in code coverage.
Specifically, if we give up inside the inlined function, the rest of
parent's basic blocks will not get analyzed.

This commit introduces an option to enable re-run along the failed path,
in which we do not inline the last inlined call site. This is done by
enqueueing the node before the processing of the inlined call site
with a special policy encoded in the state. The policy tells us not to
inline the call site along the path.

This lead to ~10% increase in the number of paths analyzed. Even though
we expected a much greater coverage improvement. 

The option is turned off by default for now.

llvm-svn: 153534
2012-03-27 20:02:53 +00:00
Douglas Gregor 41ab2899b2 Introduce a -cc1-level option -pubnames-dump, which simply dumps the
list of identifiers that that 'public' names at the end of the
translation unit, e.g., defined macros or identifiers with top-level
names, in sorted order. Meant to support <rdar://problem/10921596>.

llvm-svn: 153522
2012-03-27 18:06:49 +00:00
Benjamin Kramer e6f5123e16 Driver: Factor string vector push_back into a helper class and optimize it.
Due to lack of move semantics we would create a temporary std::string from the
string literal, copy it into the vector and discard the temporary. This leads
to massive code bloat, optimizing it saves 50k on i386-linux-Release+Asserts.

While there add a two-element overload for push_back, simplifying code a bit.

llvm-svn: 153441
2012-03-26 15:39:31 +00:00
Aaron Ballman eceaddc864 Since this change is generating a considerable amount of discussion (and possibly even a regression for known bad versions), I'm reverting it.
llvm-svn: 153420
2012-03-25 22:46:17 +00:00
Aaron Ballman 9345d68ff7 No longer hard coding paths to the MinGW include directories; using a regular expression instead.
Patch thanks to Nikola Smiljanic

llvm-svn: 153413
2012-03-25 15:47:41 +00:00
Chad Rosier 9c76d24f9c [frontend] Fix how the frontend handles -fno-inline. AFAIK clang now matches
the behavior of gcc with respect to the -fno-inline and -fno-inline-functions
flags.

llvm-svn: 152861
2012-03-15 22:31:42 +00:00
Aaron Ballman 564acc9b0f Adding in newer MinGW header paths.
Patch thanks to Nikola Smiljanic

llvm-svn: 152801
2012-03-15 14:31:30 +00:00
Chad Rosier 883b2579aa [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

llvm-svn: 152754
2012-03-14 23:32:11 +00:00
Chad Rosier d6f716ab2a [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>.

llvm-svn: 152660
2012-03-13 20:09:56 +00:00
Argyrios Kyrtzidis eeea16a0d5 [libclang] When there's a file error when saving the PCH, make sure to
clear the error from raw_fd_ostream, otherwise we will crash.

rdar://10976410

llvm-svn: 152605
2012-03-13 02:17:06 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Aaron Ballman b4489162b6 No longer defining GNUC mode when compiling for Microsoft compatibility. This allows people's cross-platform compiler-specific macros to work properly.
llvm-svn: 152512
2012-03-10 22:21:14 +00:00
Anna Zaks 394d07ea88 [analyzer] Add support for NoRedundancy inlining mode.
We do not reanalyze a function, which has already been analyzed as an
inlined callee. As per PRELIMINARY testing, this gives over
50% run time reduction on some benchmarks without decreasing of the
number of bugs found.

Turning the mode on by default.

llvm-svn: 152440
2012-03-09 21:14:01 +00:00
Daniel Dunbar 7b93f636e0 [Basic] Rename LangOptions::NoInline to NoInlineDefine, to make things a bit
more obvious.

llvm-svn: 152408
2012-03-09 15:39:08 +00:00
Anna Zaks 0af3e06ff6 [analyzer] Rework inlining related command line options.
- Remove -analyzer-inline-call.
 - Add -analyzer-ipa=[none|inlining]
 - Add -analyzer-inlining-mode to allow experimentation for
different performance tuning methods.

llvm-svn: 152351
2012-03-08 23:16:35 +00:00
Rafael Espindola df88f6fe98 Replace MarkVarRequired with a more generic
HandleCXXStaticMemberVarInstantiation. Suggested by Argyrios.

llvm-svn: 152320
2012-03-08 15:51:03 +00:00
Bob Wilson f2a23a99db Workaround module test failures by removing the version info from module hashes.
PR12196: The module hash strings are not actually hashing the compiler version
string; the entire version string is being included in the hash.  Depending on
the module cache directory name, that can lead to failures where the path
names become too long.  As a temporary workaround, just remove the version
string from the hash.

llvm-svn: 152266
2012-03-07 23:50:05 +00:00
Argyrios Kyrtzidis 4a280ff48f [PCH] Mark a PCH file with a flag to indicate if the serialized AST had
compiler errors or not.

-Control whether ASTReader should reject such a PCH by a boolean flag at ASTReader's creation time.
By default, such a PCH file will be rejected with an error when trying to load it.

[libclang] Allow clang_saveTranslationUnit to create a PCH file even if compiler errors
occurred.
-Have libclang API calls accept a PCH that had compiler errors.

The general idea is that we want libclang to stay functional even if a PCH had a compiler error.
rdar://10976363.

llvm-svn: 152192
2012-03-07 01:51:17 +00:00
NAKAMURA Takumi 66a7e43363 CMake: Fix build to add clangEdit to USED_LIBS.
llvm-svn: 152154
2012-03-06 22:32:32 +00:00
Chad Rosier 64d6be979f [driver] What was implemented in r152130 was actually -fno-inline-functions, not
-fno-inline.
Part of rdar://10972766

llvm-svn: 152145
2012-03-06 21:17:19 +00:00
Ted Kremenek f7639e1b4a Add new code migrator support for migrating existing Objective-C code to use
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax.

This introduces a new library, libEdit, which provides a new way to support
migration of code that improves on the original ARC migrator.  We now believe
that most of its functionality can be refactored into the existing libraries,
and thus this new library may shortly disappear.

llvm-svn: 152141
2012-03-06 20:06:33 +00:00
Chad Rosier 806031896d [driver] Add support for -fno-inline.
rdar://10972766

llvm-svn: 152130
2012-03-06 18:49:20 +00:00
Rafael Espindola 189fa748ec Fix a small difference in sema and codegen views of what needs to be output.
In the included testcase, soma thinks that we already have a definition after we
see the out of line decl. Codegen puts it in a deferred list, to be output if
a use is seen. This would break when we saw an explicit template instantiation
definition, since codegen would not be notified.

This patch adds a method to the consumer interface so that soma can notify
codegen that this decl is now required.

llvm-svn: 152024
2012-03-05 10:54:55 +00:00
Argyrios Kyrtzidis 647dcd80f0 [preprocessor] Enhance PreprocessingRecord to keep track of locations of conditional directives.
Introduce PreprocessingRecord::rangeIntersectsConditionalDirective() which returns
true if a given range intersects with a conditional directive block.

llvm-svn: 152018
2012-03-05 05:48:17 +00:00
Daniel Dunbar ae77b3dfad Frontend: Default to creating output files using temporary files + rename.
- This is a more reliable default, as it behaves better on failure and also
   ensures that we create *new* files (instead of reusing existing inodes). This
   is useful for other applications (like lldb) which want to cache inode's to
   know when a file has been rewritten.

llvm-svn: 151961
2012-03-03 00:36:06 +00:00
Daniel Dunbar b9c62c0773 Frontend: Don't automatically create missing directories when using temporary files with createOutputFile()
- This would otherwise happen as a side effect of llvm::sys::fs::unique_file creating parent directories.

llvm-svn: 151960
2012-03-03 00:36:02 +00:00
Anna Zaks 265087721a [analyzer] Bound the size of the functions being inlined + provide
command line options for inlining tuning.

This adds the option for stack depth bound as well as function size
bound. 

+ minor doxygenification

llvm-svn: 151930
2012-03-02 19:05:03 +00:00
David Chisnall e04307e47c Add the Solaris support directory to the header search when using libc++.
Unconditionally define __C99FEATURES__ when using C++ on Solaris.  This is a
(hopefully temporary) work around for libc++ exposing C99-but-not-C++98
features in C++98 mode.

llvm-svn: 151889
2012-03-02 10:49:52 +00:00
Anna Zaks d5c3027473 [analyzer] Turn inlining on by default for better testing exposure.
Fix a test, which was most likely an unintended recursive call.

llvm-svn: 151848
2012-03-01 22:37:46 +00:00
Kostya Serebryany 28a7a1198b Add a flag -fthread-sanitizer.
This flag enables ThreadSanitizer instrumentation committed to llvm as r150423.
The patch includes one test for -fthread-sanitizer and one similar test for -faddress-sanitizer.
This patch does not modify the linker flags (as we do it for -faddress-sanitizer) because the run-time library is not yet
committed and it's structure in compiler-rt is not 100% clear.
The users manual wil be changed in a separate commit.

llvm-svn: 151846
2012-03-01 22:27:08 +00:00
Daniel Dunbar 9a96386e6d Serialization: Switch over to using the native SmallVector based BitstreamWriter
ctor.

llvm-svn: 151752
2012-02-29 20:31:23 +00:00