History log of /llvm-project/clang/tools/clang-format/ClangFormat.cpp (Results 76 – 100 of 142)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# d274dc38 25-Feb-2017 NAKAMURA Takumi <geek4civic@gmail.com>

Revert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows, PR26125", and r296171.

(MemoryBuffer)Code.reset() was too early.

==26912== Invalid read of size 1
==26912==

Revert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows, PR26125", and r296171.

(MemoryBuffer)Code.reset() was too early.

==26912== Invalid read of size 1
==26912== at 0x437E1D: llvm::MemoryBuffer::init(char const*, char const*, bool) (MemoryBuffer.cpp:47)
==26912== by 0x438013: (anonymous namespace)::MemoryBufferMem::MemoryBufferMem(llvm::StringRef, bool) (MemoryBuffer.cpp:86)
==26912== by 0x438128: llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, llvm::StringRef, bool) (MemoryBuffer.cpp:112)
==26912== by 0x4E189D: clang::vfs::detail::(anonymous namespace)::InMemoryFileAdaptor::getBuffer(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:443)
==26912== by 0x4DF5BA: clang::vfs::FileSystem::getBufferForFile(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:94)
==26912== by 0x4B72EC: clang::FileManager::getBufferForFile(clang::FileEntry const*, bool, bool) (FileManager.cpp:443)
==26912== by 0x4C1F81: clang::SrcMgr::ContentCache::getBuffer(clang::DiagnosticsEngine&, clang::SourceManager const&, clang::SourceLocation, bool*) const (SourceManager.cpp:98)
==26912== by 0x4C50E5: clang::SourceManager::getBufferData(clang::FileID, bool*) const (SourceManager.cpp:689)
==26912== by 0x58E794: clang::Rewriter::getEditBuffer(clang::FileID) (Rewriter.cpp:230)
==26912== by 0x407297: clang::format::format(llvm::StringRef) (ClangFormat.cpp:311)
==26912== by 0x4078D7: main (ClangFormat.cpp:363)

llvm-svn: 296237

show more ...


# cc0573b0 24-Feb-2017 Nico Weber <nicolasweber@gmx.de>

clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

Fix and analysis by Wei Mao <weimao1@gmail.com> (see bug), test by me.

llvm-svn: 296166


Revision tags: llvmorg-4.0.0-rc2
# fa37b18f 27-Jan-2017 Martin Probst <martin@probst.io>

clang-format: [JS] do not format MPEG transport streams.

Summary:
The MPEG transport stream file format also uses ".ts" as its file extension.
This change detects its specific framing format (0x47 e

clang-format: [JS] do not format MPEG transport streams.

Summary:
The MPEG transport stream file format also uses ".ts" as its file extension.
This change detects its specific framing format (0x47 every 189 bytes) and
simply ignores MPEG TS files.

Reviewers: djasper, sammccall

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D29186

llvm-svn: 293270

show more ...


Revision tags: llvmorg-4.0.0-rc1
# 3adfb6a3 17-Jan-2017 Antonio Maiorano <amaiorano@gmail.com>

clang-format: Make GetStyle return Expected<FormatStyle> instead of FormatStyle

Change the contract of GetStyle so that it returns an error when an error occurs
(i.e. when it writes to stderr), and

clang-format: Make GetStyle return Expected<FormatStyle> instead of FormatStyle

Change the contract of GetStyle so that it returns an error when an error occurs
(i.e. when it writes to stderr), and only returns the fallback style when it
can't find a configuration file.

Differential Revision: https://reviews.llvm.org/D28081

llvm-svn: 292174

show more ...


# 03a04fe9 12-Dec-2016 Daniel Jasper <djasper@google.com>

clang-format: Separate out a language kind for ObjC.

While C(++) and ObjC are generally formatted the same way and can be
mixed, people might want to choose different styles based on the
language. T

clang-format: Separate out a language kind for ObjC.

While C(++) and ObjC are generally formatted the same way and can be
mixed, people might want to choose different styles based on the
language. This patch recognizes .m and .mm files as ObjC and also
implements a very crude detection of whether or not a .h file contains
ObjC code. This can be improved over time.

Also move most of the ObjC tests into their own test file to keep file
size maintainable.

llvm-svn: 289428

show more ...


Revision tags: llvmorg-3.9.1, llvmorg-3.9.1-rc3, llvmorg-3.9.1-rc2, llvmorg-3.9.1-rc1, llvmorg-3.9.0, llvmorg-3.9.0-rc3, llvmorg-3.9.0-rc2
# a992afe8 10-Aug-2016 Eric Liu <ioeric@google.com>

Make clang-format remove duplicate headers when sorting #includes.

Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only

Make clang-format remove duplicate headers when sorting #includes.

Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the `Cursor` is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D23274

llvm-svn: 278206

show more ...


# 40ef2fb3 01-Aug-2016 Eric Liu <ioeric@google.com>

Implement tooling::Replacements as a class.

Summary:
- Implement clang::tooling::Replacements as a class to provide interfaces to
control how replacements for a single file are combined and provid

Implement tooling::Replacements as a class.

Summary:
- Implement clang::tooling::Replacements as a class to provide interfaces to
control how replacements for a single file are combined and provide guarantee
on the order of replacements being applied.
- tooling::Replacements only contains replacements for the same file now.
Use std::map<std::string, tooling::Replacements> to represent multi-file
replacements.
- Error handling for the interface change will be improved in followup patches.

Reviewers: djasper, klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D21748

llvm-svn: 277335

show more ...


Revision tags: llvmorg-3.9.0-rc1
# 9670f847 18-Jul-2016 Mehdi Amini <mehdi.amini@apple.com>

[NFC] Header cleanup

Summary: Removed unused headers, replaced some headers with forward class declarations

Patch by: Eugene <claprix@yandex.ru>

Differential Revision: https://reviews.llvm.org/D20

[NFC] Header cleanup

Summary: Removed unused headers, replaced some headers with forward class declarations

Patch by: Eugene <claprix@yandex.ru>

Differential Revision: https://reviews.llvm.org/D20100

llvm-svn: 275882

show more ...


# 4f8d9943 11-Jul-2016 Eric Liu <ioeric@google.com>

Make tooling::applyAllReplacements return llvm::Expected<string> instead of empty string to indicate potential error.

Summary:
return llvm::Expected<> to carry error status and error information.
Th

Make tooling::applyAllReplacements return llvm::Expected<string> instead of empty string to indicate potential error.

Summary:
return llvm::Expected<> to carry error status and error information.
This is the first step towards introducing "Error" into tooling::Replacements.

Reviewers: djasper, klimek

Subscribers: ioeric, klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D21601

llvm-svn: 275062

show more ...


# dfed58a5 09-Jun-2016 Richard Smith <richard-llvm@metafoo.co.uk>

Update to match LLVM r272232.

llvm-svn: 272233


Revision tags: llvmorg-3.8.1, llvmorg-3.8.1-rc1, llvmorg-3.8.0, llvmorg-3.8.0-rc3, llvmorg-3.8.0-rc2, llvmorg-3.8.0-rc1, llvmorg-3.7.1
# b68aabf7 23-Nov-2015 Daniel Jasper <djasper@google.com>

clang-format: Make moving of the Cursor work properly when sorting #includes.

llvm-svn: 253860


Revision tags: llvmorg-3.7.1-rc2, llvmorg-3.7.1-rc1
# da446770 16-Nov-2015 Daniel Jasper <djasper@google.com>

clang-format: Enable #include sorting by default.

This has seen quite some usage and I am not aware of any issues. Also
add a style option to enable/disable include sorting. The existing
command lin

clang-format: Enable #include sorting by default.

This has seen quite some usage and I am not aware of any issues. Also
add a style option to enable/disable include sorting. The existing
command line flag can from now on be used to override whatever is set
in the style.

llvm-svn: 253202

show more ...


# 373ee96e 19-Oct-2015 Nico Weber <nicolasweber@gmx.de>

Update list of languages advertised in OVERVIEW: A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.

If no arguments are specified, it formats the code from standard input
and writes t

Update list of languages advertised in OVERVIEW: A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.

If no arguments are specified, it formats the code from standard input
and writes the result to the standard output.
If <file>s are given, it reformats the files. If -i is specified
together with <file>s, the files are edited in-place. Otherwise, the
result is written to the standard output.

USAGE: clang-format [options] [<file> ...]

OPTIONS:
-assume-filename=<string> - When reading from stdin, clang-format assumes this
filename to look for a style config file (with
-style=file) and to determine the language.
-cursor=<uint> - The position of the cursor when invoking
clang-format from an editor integration
-dump-config - Dump configuration options to stdout and exit.
Can be used with -style option.
-fallback-style=<string> - The name of the predefined style used as a
fallback in case clang-format is invoked with
-style=file, but can not find the .clang-format
file to use.
Use -fallback-style=none to skip formatting.
-help - Display available options (-help-hidden for more)
-i - Inplace edit <file>s, if specified.
-length=<uint> - Format a range of this length (in bytes).
Multiple ranges can be formatted by specifying
several -offset and -length pairs.
When only a single -offset is specified without
-length, clang-format will format up to the end
of the file.
Can only be used with one input file.
-lines=<string> - <start line>:<end line> - format a range of
lines (both 1-based).
Multiple ranges can be formatted by specifying
several -lines arguments.
Can't be used with -offset and -length.
Can only be used with one input file.
-offset=<uint> - Format a range starting at this byte offset.
Multiple ranges can be formatted by specifying
several -offset and -length pairs.
Can only be used with one input file.
-output-replacements-xml - Output replacements as XML.
-sort-includes - Sort touched include lines
-style=<string> - Coding style, currently supports:
LLVM, Google, Chromium, Mozilla, WebKit.
Use -style=file to load style configuration from
.clang-format file located in one of the parent
directories of the source file (or current
directory for stdin).
Use -style="{key: value, ...}" to set specific
parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 8}"
-version - Display the version of this program output.

llvm-svn: 250671

show more ...


# f39757d0 15-Oct-2015 Daniel Jasper <djasper@google.com>

clang-format: Basic escaping when outputting XML.

llvm-svn: 250440


# 2e2351ad 06-Oct-2015 Benjamin Kramer <benny.kra@googlemail.com>

[VFS] Transition clang-format to use an in-memory FS.

Apart from being cleaner this also means that clang-format no longer has
access to the host file system. This isn't necessary because clang-form

[VFS] Transition clang-format to use an in-memory FS.

Apart from being cleaner this also means that clang-format no longer has
access to the host file system. This isn't necessary because clang-format
never reads includes :)

Includes minor tweaks and bugfixes found in the VFS implementation while
running clang-format tests.

llvm-svn: 249385

show more ...


# 867a9382 30-Sep-2015 Daniel Jasper <djasper@google.com>

clang-format: Use Rewriter again to write the output files.

This has two advantages:
1. Atomic writes.
2. Proper handling of line endings (hopefully solving llvm.org/PR24999

llvm-svn: 248904


# 85c472dc 29-Sep-2015 Daniel Jasper <djasper@google.com>

clang-format: Extend #include sorting functionality

Recognize the main module header as well as different #include categories.
This should now mimic the behavior of llvm/utils/sort_includes.py as
we

clang-format: Extend #include sorting functionality

Recognize the main module header as well as different #include categories.
This should now mimic the behavior of llvm/utils/sort_includes.py as
well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very
closely.

llvm-svn: 248782

show more ...


# d89ae9d3 23-Sep-2015 Daniel Jasper <djasper@google.com>

clang-format: Add initial #include sorting capabilities.

To implement this nicely, add a function that merges two sets of
replacements that are meant to be done in sequence. This functionality
will

clang-format: Add initial #include sorting capabilities.

To implement this nicely, add a function that merges two sets of
replacements that are meant to be done in sequence. This functionality
will also be useful for other applications, e.g. formatting the result
of clang-tidy fixes.

llvm-svn: 248367

show more ...


Revision tags: llvmorg-3.7.0, llvmorg-3.7.0-rc4, llvmorg-3.7.0-rc3, studio-1.4, llvmorg-3.7.0-rc2, llvmorg-3.7.0-rc1, llvmorg-3.6.2, llvmorg-3.6.2-rc1, llvmorg-3.6.1, llvmorg-3.6.1-rc1
# 622c72de 10-May-2015 Daniel Jasper <djasper@google.com>

Reapply r236854 and fixed r236867.

Makes emacs show a different message when clang-format encountered a
syntax error.

llvm-svn: 236943


# a7046002 08-May-2015 Tobias Grosser <tobias@grosser.es>

Revert "Make emacs show when clang-format encountered a syntax error."

This reverts commit 236854, which caused clang-format to always print
'{ "IncompleteFormat": false }' at the top of an incomple

Revert "Make emacs show when clang-format encountered a syntax error."

This reverts commit 236854, which caused clang-format to always print
'{ "IncompleteFormat": false }' at the top of an incompletely formatted file.
This output causes problems e.g. in Polly's automatic formatting checks. Daniel
tried to fix this in 236867, but this fix had to be reverted due to buildbot
failures. I revert this change as well for now as it is Friday night and
unlikely to be fixed immediately.

llvm-svn: 236908

show more ...


# 82fbfe68 08-May-2015 Renato Golin <renato.golin@linaro.org>

Revert "clang-format: Only output IncompleteFormat if -cursor is given."

This reverts commit r236867, as it was breaking multiple buildbots. Daniel
will look into it later.

llvm-svn: 236882


# e44e5665 08-May-2015 Daniel Jasper <djasper@google.com>

clang-format: Only output IncompleteFormat if -cursor is given.

This is only for editor integrations.

llvm-svn: 236867


# 3dfe4a87 08-May-2015 Manuel Klimek <klimek@google.com>

Make emacs show when clang-format encountered a syntax error.

Propagate the 'incomplete-format' state back through clang-format's command
line interace and adapt the emacs integration to show a bett

Make emacs show when clang-format encountered a syntax error.

Propagate the 'incomplete-format' state back through clang-format's command
line interace and adapt the emacs integration to show a better result.

llvm-svn: 236854

show more ...


# fc510b67 06-May-2015 Daniel Jasper <djasper@google.com>

clang-format: Don't allow -i when reading from stdin.

llvm-svn: 236592


Revision tags: llvmorg-3.5.2, llvmorg-3.5.2-rc1, llvmorg-3.6.0, llvmorg-3.6.0-rc4, llvmorg-3.6.0-rc3, llvmorg-3.6.0-rc2
# 0a9f607f 21-Jan-2015 Chris Bieneman <beanz@apple.com>

Adopt new cl::HideUnrelatedOptions API added r226729.

Summary: cl::HideUnrelatedOptions allows tools to hide all options not part of a specific OptionCategory. This is the common use case for cl::ge

Adopt new cl::HideUnrelatedOptions API added r226729.

Summary: cl::HideUnrelatedOptions allows tools to hide all options not part of a specific OptionCategory. This is the common use case for cl::getRegisteredOptions, which should be deprecated in the future because it exposes implementation details of command line parsing.

Reviewers: dexonsmith

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D7109

llvm-svn: 226741

show more ...


123456