aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/PTHLexer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-12-04PTH-- Remove feature entirely-Erich Keane1-748/+0
When debugging a boost build with a modified version of Clang, I discovered that the PTH implementation stores TokenKind in 8 bits. However, we currently have 368 TokenKinds. The result is that the value gets truncated and the wrong token gets picked up when including PTH files. It seems that this will go wrong every time someone uses a token that uses the 9th bit. Upon asking on IRC, it was brought up that this was a highly experimental features that was considered a failure. I discovered via googling that BoostBuild (mostly Boost.Math) is the only user of this feature, using the CC1 flag directly. I believe that this can be transferred over to normal PCH with minimal effort: https://github.com/boostorg/build/issues/367 Based on advice on IRC and research showing that this is a nearly completely unused feature, this patch removes it entirely. Note: I considered leaving the build-flags in place and making them emit an error/warning, however since I've basically identified and warned the only user, it seemed better to just remove them. Differential Revision: https://reviews.llvm.org/D54547 Change-Id: If32744275ef1f585357bd6c1c813d96973c4d8d9 llvm-svn: 348266
2018-10-10Lift VFS from clang to llvm (NFC)Jonas Devlieghere1-2/+2
This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
2018-04-06Fix typos in clangAlexander Kornienko1-1/+1
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
2018-02-26Re-land: "[Support] Replace HashString with djbHash."Jonas Devlieghere1-4/+4
This patch removes the HashString function from StringExtraces and replaces its uses with calls to djbHash from DJB.h. This change is *almost* NFC. While the algorithm is identical, the djbHash implementation in StringExtras used 0 as its default seed while the implementation in DJB uses 5381. The latter has been shown to result in less collisions and improved avalanching and is used by the DWARF accelerator tables. Because some test were implicitly relying on the hash order, I've reverted to using zero as a seed for the following two files: lld/include/lld/Core/SymbolTable.h llvm/lib/Support/StringMap.cpp Differential revision: https://reviews.llvm.org/D43615 llvm-svn: 326091
2018-02-26Revert "[Support] Replace HashString with djbHash."Jonas Devlieghere1-4/+4
It looks like some of our tests depend on the ordering of hashed values. I'm reverting my changes while I try to reproduce and fix this locally. Failing builds: lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/18388 lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/6743 lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/15607 llvm-svn: 326082
2018-02-26[Support] Replace HashString with djbHash.Jonas Devlieghere1-4/+4
This removes the HashString function from StringExtraces and replaces its uses with calls to djbHash from DJB.h This is *almost* NFC. While the algorithm is identical, the djbHash implementation in StringExtras used 0 as its seed while the implementation in DJB uses 5381. The latter has been shown to result in less collisions and improved avalanching. https://reviews.llvm.org/D43615 (cherry picked from commit 77f7f965bc9499a9ae768a296ca5a1f7347d1d2c) llvm-svn: 326081
2017-12-06[Lex] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko1-34/+55
minor fixes (NFC). llvm-svn: 319986
2016-10-11Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)Mehdi Amini1-3/+3
llvm-svn: 283856
2016-10-10Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini1-3/+3
llvm-svn: 283815
2016-08-24Remove excessive padding from PTHStatData (NFC)Mehdi Amini1-2/+2
This diff reorders the fields and removes excessive padding. This fixes the following warning: PTHLexer.cpp:629:7: warning: Excessive padding in 'class (anonymous namespace)::PTHStatData' (14 padding bytes, where 6 is optimal). Optimal fields order: Size, ModTime, UniqueID, HasData, IsDirectory, consider reordering the fields or adding explicit padding members. Patch by: Alexander Shaposhnikov <shal1t712@gmail.com> Differential Revision: https://reviews.llvm.org/D23826 llvm-svn: 279607
2016-07-18[NFC] Header cleanupMehdi Amini1-1/+0
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
2015-10-20Roll-back r250822.Angel Garcia Gomez1-1/+2
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-2/+1
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-1/+1
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-06-01Replace a few std::string& with StringRef. NFC.Rafael Espindola1-2/+1
Patch by Косов Евгений! llvm-svn: 238774
2014-08-29unique_ptrify PTHManager's PerIDCache using the newly added llvm::FreeDeleterDavid Blaikie1-14/+12
llvm-svn: 216786
2014-08-29unique_ptrify some parameters to PTHManager::PTHManagerDavid Blaikie1-35/+29
A couple of these arguments were passed by void* as a rather extreme example of pimpling. Adjusting this to a more classic form of the idiom (involving forward declarations) makes this more legible and allows explicit passing of ownership via std::unique_ptr. llvm-svn: 216785
2014-08-18Update the call to llvm::sys::fs::UniqueID to match the definition: ↵Sylvestre Ledru1-1/+1
UniqueID(uint64_t Device, uint64_t File) Fixes CID 1095247 llvm-svn: 215896
2014-08-11unique_ptr-ify FileSystemStatCache::setNextStatCacheDavid Blaikie1-2/+2
And in the process, discover that FileManager::removeStatCache had a double-delete when removing an element from the middle of the list (at the beginning or the end of the list, there was no problem) and add a unit test to exercise the code path (which successfully crashed when run (with modifications to match the old API) without this patch applied) llvm-svn: 215388
2014-07-08Improve memory ownership of vfs::Files in the FileSystemStatCache by using ↵David Blaikie1-3/+2
std::unique_ptr Spotted after a memory leak (due to the complexities of manual memory management) was fixed in 212466. llvm-svn: 212541
2014-07-07PTH: use a variable instead of a macroAlp Toker1-8/+10
Cleanup only. llvm-svn: 212457
2014-07-06Update for llvm api change.Rafael Espindola1-2/+4
llvm-svn: 212408
2014-06-12Include system_error directly.Rafael Espindola1-1/+1
llvm-svn: 210802
2014-05-17[C++11] Use 'nullptr'. Lex edition.Craig Topper1-18/+18
llvm-svn: 209083
2014-04-18Teach users of OnDiskHashTable to define hash_value and offset typesJustin Bogner1-8/+8
This paves the way to making OnDiskHashTable work with hashes that are not 32 bits wide and to making OnDiskHashTable work very large hash tables. The LLVM change to use these types is upcoming. llvm-svn: 206640
2014-04-18Remove OnDiskHashTable.h, since it's been moved to llvmJustin Bogner1-5/+4
llvm-svn: 206637
2014-03-28Reapply "OnDiskHashTable: Use Endian.h to read little endian ostreams"Justin Bogner1-29/+57
Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to read little endian data from a buffer, we can use the support in llvm's Endian.h. No functional change. llvm-svn: 205062
2014-03-28Reapply "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner1-0/+1
Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205061
2014-03-28Revert "OnDiskHashTable: Use Endian.h to read little endian ostreams"Justin Bogner1-57/+29
This reverts commit r205045. llvm-svn: 205048
2014-03-28Revert "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner1-1/+0
This reverts commit r205044. llvm-svn: 205047
2014-03-28OnDiskHashTable: Use Endian.h to read little endian ostreamsJustin Bogner1-29/+57
Rather than rolling our own functions to read little endian data from a buffer, we can use the support in llvm's Endian.h. No functional change. llvm-svn: 205045
2014-03-28OnDiskHashTable: Use EndianStream.h to write little endian ostreamsJustin Bogner1-0/+1
Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205044
2014-03-11[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-1/+1
class. llvm-svn: 203547
2014-03-09[C++11] Replace OwningPtr include with <memory>.Ahmed Charles1-1/+1
llvm-svn: 203389
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-4/+4
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-3/+3
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
2014-02-28Reapply fixed "Honour 'use-external-names' in FileManager"Ben Langmuir1-0/+1
Was r202442 There were two issues with the original patch that have now been fixed. 1. We were memset'ing over a FileEntry in a test case. After adding a std::string to FileEntry, this still happened to not break for me. 2. I didn't pass the FileManager into the new compiler instance in compileModule. This was hidden in some cases by the fact I didn't clear the module cache in the test. Also, I changed the copy constructor for FileEntry, which was memcpy'ing in a (now) unsafe way. llvm-svn: 202539
2014-02-27Revert "Honour 'use-external-names' in FileManager"Ben Langmuir1-1/+0
Revert r202442, which broke the buildbots. llvm-svn: 202443
2014-02-27Honour 'use-external-names' in FileManagerBen Langmuir1-0/+1
Pass through the externally-visible names that we got from the VFS down to FileManager, and test that this is the name showing up in __FILE__, diagnostics, and debug information. llvm-svn: 202442
2014-02-20Recommit virtual file systemBen Langmuir1-2/+2
Previously reverted in r201755 due to causing an assertion failure. I've removed the offending assertion, and taught the CompilerInstance to create a default virtual file system inside createFileManager. In the future, we should be able to reach into the CompilerInvocation to customize this behaviour without breaking clients that don't care. llvm-svn: 201818
2014-02-20Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka1-2/+2
assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
2014-02-19Initial implementation of virtual file systemBen Langmuir1-2/+2
This adds the minimum virtual file system support to start migrating FileManager onto the VFS. Originally discussed here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html Differential Revision: http://llvm-reviews.chandlerc.com/D2745 llvm-svn: 201618
2014-01-26Enforce safe usage of DiagnosticsEngine::getCustomDiagID()Alp Toker1-1/+1
Replace the last incorrect uses and templatize the function to require a compile-time constant string preventing further misuse. The diagnostic formatter expects well-formed input and has undefined behaviour with arbitrary input or crafted user strings in source files. Accepting user input would also have caused unbounded generation of new diagnostic IDs which can be problematic in long-running sessions or language bindings. This completes the work to fix several incorrect callers that passed user input or raw messages to the diagnostics engine where a constant format string was expected. llvm-svn: 200132
2013-09-19Make Preprocessor::Lex non-recursive.Eli Friedman1-17/+8
Before this patch, Lex() would recurse whenever the current lexer changed (e.g. upon entry into a macro). This patch turns the recursion into a loop: the various lex routines now don't return a token when the current lexer changes, and at the top level Preprocessor::Lex() now loops until it finds a token. Normally, the recursion wouldn't end up being very deep, but the recursion depth can explode in edge cases like a bunch of consecutive macros which expand to nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this patch). <rdar://problem/14569770> llvm-svn: 190980
2013-08-01Use llvm::sys::fs::UniqueID for windows and unix.Rafael Espindola1-28/+36
This unifies the unix and windows versions of FileManager::UniqueDirContainer and FileManager::UniqueFileContainer by using UniqueID. We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we want to be able to construct fake ones, and file_status has different members on unix and windows. What the patch does is: * Record only the information that clang is actually using. * Use llvm::sys::fs::status instead of stat and fstat. * Use llvm::sys::fs::UniqueID * Delete the old windows versions of UniqueDirContainer and UniqueFileContainer since the "unix" one now works on windows too. llvm-svn: 187619
2012-12-21Remove duplicate includes.Roman Divacky1-1/+0
llvm-svn: 170903
2012-12-11Extend stat query APIs to explicitly specify if the query is forArgyrios Kyrtzidis1-2/+2
a file or directory, allowing just a stat call if a file descriptor is not needed. Doing just 'stat' is faster than 'open/fstat/close'. This has the effect of cutting down system time for validating the input files of a PCH. llvm-svn: 169831
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-4/+4
uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
2012-09-16Fix dead store found by static analyzer.Ted Kremenek1-5/+2
llvm-svn: 163994