Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,28 @@
#include "clang/Basic/Attributes.h"
#include "clang/Basic/AttrSubjectMatchRules.h"
#include "clang/Basic/IdentifierTable.h"
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
int clang::hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
const IdentifierInfo *Attr, const TargetInfo &Target,
const LangOptions &LangOpts) {
StringRef Name = Attr->getName();
// Normalize the attribute name, __foo__ becomes foo.
if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
Name = Name.substr(2, Name.size() - 4);
#include "clang/Basic/AttrHasAttributeImpl.inc"
return 0;
}
const char *attr::getSubjectMatchRuleSpelling(attr::SubjectMatchRule Rule) {
switch (Rule) {
#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
case attr::NAME: \
return SPELLING;
#include "clang/Basic/AttrSubMatchRulesList.inc"
}
llvm_unreachable("Invalid subject match rule");
}

View File

@ -0,0 +1,141 @@
//===--- Builtins.cpp - Builtin function implementation -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements various things for builtin functions.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Builtins.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringRef.h"
using namespace clang;
static const Builtin::Info BuiltinInfo[] = {
{ "not a builtin function", nullptr, nullptr, nullptr, ALL_LANGUAGES,nullptr},
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LANGBUILTIN(ID, TYPE, ATTRS, LANGS) \
{ #ID, TYPE, ATTRS, nullptr, LANGS, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, LANGS) \
{ #ID, TYPE, ATTRS, HEADER, LANGS, nullptr },
#include "clang/Basic/Builtins.def"
};
const Builtin::Info &Builtin::Context::getRecord(unsigned ID) const {
if (ID < Builtin::FirstTSBuiltin)
return BuiltinInfo[ID];
assert(((ID - Builtin::FirstTSBuiltin) <
(TSRecords.size() + AuxTSRecords.size())) &&
"Invalid builtin ID!");
if (isAuxBuiltinID(ID))
return AuxTSRecords[getAuxBuiltinID(ID) - Builtin::FirstTSBuiltin];
return TSRecords[ID - Builtin::FirstTSBuiltin];
}
void Builtin::Context::InitializeTarget(const TargetInfo &Target,
const TargetInfo *AuxTarget) {
assert(TSRecords.empty() && "Already initialized target?");
TSRecords = Target.getTargetBuiltins();
if (AuxTarget)
AuxTSRecords = AuxTarget->getTargetBuiltins();
}
bool Builtin::Context::isBuiltinFunc(const char *Name) {
StringRef FuncName(Name);
for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin; ++i)
if (FuncName.equals(BuiltinInfo[i].Name))
return strchr(BuiltinInfo[i].Attributes, 'f') != nullptr;
return false;
}
bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo,
const LangOptions &LangOpts) {
bool BuiltinsUnsupported =
(LangOpts.NoBuiltin || LangOpts.isNoBuiltinFunc(BuiltinInfo.Name)) &&
strchr(BuiltinInfo.Attributes, 'f');
bool MathBuiltinsUnsupported =
LangOpts.NoMathBuiltin && BuiltinInfo.HeaderName &&
llvm::StringRef(BuiltinInfo.HeaderName).equals("math.h");
bool GnuModeUnsupported = !LangOpts.GNUMode && (BuiltinInfo.Langs & GNU_LANG);
bool MSModeUnsupported =
!LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG);
bool ObjCUnsupported = !LangOpts.ObjC1 && BuiltinInfo.Langs == OBJC_LANG;
bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 &&
(BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) == OCLC1X_LANG;
bool OclC2Unsupported = LangOpts.OpenCLVersion != 200 &&
(BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG;
bool OclCUnsupported = !LangOpts.OpenCL &&
(BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);
bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG;
return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported &&
!OclC1Unsupported && !OclC2Unsupported && !OpenMPUnsupported &&
!GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported;
}
/// initializeBuiltins - Mark the identifiers for all the builtins with their
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
/// such.
void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
const LangOptions& LangOpts) {
// Step #1: mark all target-independent builtins with their ID's.
for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i)
if (builtinIsSupported(BuiltinInfo[i], LangOpts)) {
Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
}
// Step #2: Register target-specific builtins.
for (unsigned i = 0, e = TSRecords.size(); i != e; ++i)
if (builtinIsSupported(TSRecords[i], LangOpts))
Table.get(TSRecords[i].Name).setBuiltinID(i + Builtin::FirstTSBuiltin);
// Step #3: Register target-specific builtins for AuxTarget.
for (unsigned i = 0, e = AuxTSRecords.size(); i != e; ++i)
Table.get(AuxTSRecords[i].Name)
.setBuiltinID(i + Builtin::FirstTSBuiltin + TSRecords.size());
}
void Builtin::Context::forgetBuiltin(unsigned ID, IdentifierTable &Table) {
Table.get(getRecord(ID).Name).setBuiltinID(0);
}
bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx,
bool &HasVAListArg, const char *Fmt) const {
assert(Fmt && "Not passed a format string");
assert(::strlen(Fmt) == 2 &&
"Format string needs to be two characters long");
assert(::toupper(Fmt[0]) == Fmt[1] &&
"Format string is not in the form \"xX\"");
const char *Like = ::strpbrk(getRecord(ID).Attributes, Fmt);
if (!Like)
return false;
HasVAListArg = (*Like == Fmt[1]);
++Like;
assert(*Like == ':' && "Format specifier must be followed by a ':'");
++Like;
assert(::strchr(Like, ':') && "Format specifier must end with a ':'");
FormatIdx = ::strtol(Like, nullptr, 10);
return true;
}
bool Builtin::Context::isPrintfLike(unsigned ID, unsigned &FormatIdx,
bool &HasVAListArg) {
return isLike(ID, FormatIdx, HasVAListArg, "pP");
}
bool Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx,
bool &HasVAListArg) {
return isLike(ID, FormatIdx, HasVAListArg, "sS");
}

View File

@ -0,0 +1,101 @@
set(LLVM_LINK_COMPONENTS
Core
MC
Support
)
find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
find_first_existing_vc_file(clang_vc "${CLANG_SOURCE_DIR}")
# The VC revision include that we want to generate.
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc")
set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake")
if(DEFINED llvm_vc AND DEFINED clang_vc)
# Create custom target to generate the VC revision include.
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${llvm_vc}" "${clang_vc}" "${get_svn_script}"
COMMAND
${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
"-DFIRST_NAME=LLVM"
"-DSECOND_SOURCE_DIR=${CLANG_SOURCE_DIR}"
"-DSECOND_NAME=SVN"
"-DHEADER_FILE=${version_inc}"
-P "${get_svn_script}")
# Mark the generated header as being generated.
set_source_files_properties("${version_inc}"
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)
# Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
set_source_files_properties(Version.cpp
PROPERTIES COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC")
else()
# Not producing a VC revision include.
set(version_inc)
# Being able to force-set the SVN revision in cases where it isn't available
# is useful for performance tracking, and matches compatibility from autoconf.
if(SVN_REVISION)
set_source_files_properties(Version.cpp
PROPERTIES COMPILE_DEFINITIONS "SVN_REVISION=\"${SVN_REVISION}\"")
endif()
endif()
add_clang_library(clangBasic
Attributes.cpp
Builtins.cpp
CharInfo.cpp
Cuda.cpp
Diagnostic.cpp
DiagnosticIDs.cpp
DiagnosticOptions.cpp
FileManager.cpp
FileSystemStatCache.cpp
IdentifierTable.cpp
LangOptions.cpp
MemoryBufferCache.cpp
Module.cpp
ObjCRuntime.cpp
OpenMPKinds.cpp
OperatorPrecedence.cpp
SanitizerBlacklist.cpp
SanitizerSpecialCaseList.cpp
Sanitizers.cpp
SourceLocation.cpp
SourceManager.cpp
TargetInfo.cpp
Targets.cpp
Targets/AArch64.cpp
Targets/AMDGPU.cpp
Targets/ARM.cpp
Targets/AVR.cpp
Targets/BPF.cpp
Targets/Hexagon.cpp
Targets/Lanai.cpp
Targets/Le64.cpp
Targets/MSP430.cpp
Targets/Mips.cpp
Targets/NVPTX.cpp
Targets/Nios2.cpp
Targets/OSTargets.cpp
Targets/PNaCl.cpp
Targets/PPC.cpp
Targets/SPIR.cpp
Targets/Sparc.cpp
Targets/SystemZ.cpp
Targets/TCE.cpp
Targets/WebAssembly.cpp
Targets/X86.cpp
Targets/XCore.cpp
TokenKinds.cpp
Version.cpp
VersionTuple.cpp
VirtualFileSystem.cpp
Warnings.cpp
XRayLists.cpp
${version_inc}
)

View File

@ -0,0 +1,81 @@
//===--- CharInfo.cpp - Static Data for Classifying ASCII Characters ------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/CharInfo.h"
using namespace clang::charinfo;
// Statically initialize CharInfo table based on ASCII character set
// Reference: FreeBSD 7.2 /usr/share/misc/ascii
const uint16_t clang::charinfo::InfoTable[256] = {
// 0 NUL 1 SOH 2 STX 3 ETX
// 4 EOT 5 ENQ 6 ACK 7 BEL
0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 ,
// 8 BS 9 HT 10 NL 11 VT
//12 NP 13 CR 14 SO 15 SI
0 , CHAR_HORZ_WS, CHAR_VERT_WS, CHAR_HORZ_WS,
CHAR_HORZ_WS, CHAR_VERT_WS, 0 , 0 ,
//16 DLE 17 DC1 18 DC2 19 DC3
//20 DC4 21 NAK 22 SYN 23 ETB
0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 ,
//24 CAN 25 EM 26 SUB 27 ESC
//28 FS 29 GS 30 RS 31 US
0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 ,
//32 SP 33 ! 34 " 35 #
//36 $ 37 % 38 & 39 '
CHAR_SPACE , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
//40 ( 41 ) 42 * 43 +
//44 , 45 - 46 . 47 /
CHAR_PUNCT , CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL ,
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_PERIOD , CHAR_RAWDEL ,
//48 0 49 1 50 2 51 3
//52 4 53 5 54 6 55 7
CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT ,
CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT ,
//56 8 57 9 58 : 59 ;
//60 < 61 = 62 > 63 ?
CHAR_DIGIT , CHAR_DIGIT , CHAR_RAWDEL , CHAR_RAWDEL ,
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
//64 @ 65 A 66 B 67 C
//68 D 69 E 70 F 71 G
CHAR_PUNCT , CHAR_XUPPER , CHAR_XUPPER , CHAR_XUPPER ,
CHAR_XUPPER , CHAR_XUPPER , CHAR_XUPPER , CHAR_UPPER ,
//72 H 73 I 74 J 75 K
//76 L 77 M 78 N 79 O
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_UPPER ,
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_UPPER ,
//80 P 81 Q 82 R 83 S
//84 T 85 U 86 V 87 W
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_UPPER ,
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_UPPER ,
//88 X 89 Y 90 Z 91 [
//92 \ 93 ] 94 ^ 95 _
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_RAWDEL ,
CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_UNDER ,
//96 ` 97 a 98 b 99 c
//100 d 101 e 102 f 103 g
CHAR_PUNCT , CHAR_XLOWER , CHAR_XLOWER , CHAR_XLOWER ,
CHAR_XLOWER , CHAR_XLOWER , CHAR_XLOWER , CHAR_LOWER ,
//104 h 105 i 106 j 107 k
//108 l 109 m 110 n 111 o
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_LOWER ,
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_LOWER ,
//112 p 113 q 114 r 115 s
//116 t 117 u 118 v 119 w
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_LOWER ,
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_LOWER ,
//120 x 121 y 122 z 123 {
//124 | 125 } 126 ~ 127 DEL
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_RAWDEL ,
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL , 0
};

View File

@ -0,0 +1,195 @@
#include "clang/Basic/Cuda.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorHandling.h"
namespace clang {
const char *CudaVersionToString(CudaVersion V) {
switch (V) {
case CudaVersion::UNKNOWN:
return "unknown";
case CudaVersion::CUDA_70:
return "7.0";
case CudaVersion::CUDA_75:
return "7.5";
case CudaVersion::CUDA_80:
return "8.0";
case CudaVersion::CUDA_90:
return "9.0";
}
llvm_unreachable("invalid enum");
}
const char *CudaArchToString(CudaArch A) {
switch (A) {
case CudaArch::UNKNOWN:
return "unknown";
case CudaArch::SM_20:
return "sm_20";
case CudaArch::SM_21:
return "sm_21";
case CudaArch::SM_30:
return "sm_30";
case CudaArch::SM_32:
return "sm_32";
case CudaArch::SM_35:
return "sm_35";
case CudaArch::SM_37:
return "sm_37";
case CudaArch::SM_50:
return "sm_50";
case CudaArch::SM_52:
return "sm_52";
case CudaArch::SM_53:
return "sm_53";
case CudaArch::SM_60:
return "sm_60";
case CudaArch::SM_61:
return "sm_61";
case CudaArch::SM_62:
return "sm_62";
case CudaArch::SM_70:
return "sm_70";
}
llvm_unreachable("invalid enum");
}
CudaArch StringToCudaArch(llvm::StringRef S) {
return llvm::StringSwitch<CudaArch>(S)
.Case("sm_20", CudaArch::SM_20)
.Case("sm_21", CudaArch::SM_21)
.Case("sm_30", CudaArch::SM_30)
.Case("sm_32", CudaArch::SM_32)
.Case("sm_35", CudaArch::SM_35)
.Case("sm_37", CudaArch::SM_37)
.Case("sm_50", CudaArch::SM_50)
.Case("sm_52", CudaArch::SM_52)
.Case("sm_53", CudaArch::SM_53)
.Case("sm_60", CudaArch::SM_60)
.Case("sm_61", CudaArch::SM_61)
.Case("sm_62", CudaArch::SM_62)
.Case("sm_70", CudaArch::SM_70)
.Default(CudaArch::UNKNOWN);
}
const char *CudaVirtualArchToString(CudaVirtualArch A) {
switch (A) {
case CudaVirtualArch::UNKNOWN:
return "unknown";
case CudaVirtualArch::COMPUTE_20:
return "compute_20";
case CudaVirtualArch::COMPUTE_30:
return "compute_30";
case CudaVirtualArch::COMPUTE_32:
return "compute_32";
case CudaVirtualArch::COMPUTE_35:
return "compute_35";
case CudaVirtualArch::COMPUTE_37:
return "compute_37";
case CudaVirtualArch::COMPUTE_50:
return "compute_50";
case CudaVirtualArch::COMPUTE_52:
return "compute_52";
case CudaVirtualArch::COMPUTE_53:
return "compute_53";
case CudaVirtualArch::COMPUTE_60:
return "compute_60";
case CudaVirtualArch::COMPUTE_61:
return "compute_61";
case CudaVirtualArch::COMPUTE_62:
return "compute_62";
case CudaVirtualArch::COMPUTE_70:
return "compute_70";
}
llvm_unreachable("invalid enum");
}
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S) {
return llvm::StringSwitch<CudaVirtualArch>(S)
.Case("compute_20", CudaVirtualArch::COMPUTE_20)
.Case("compute_30", CudaVirtualArch::COMPUTE_30)
.Case("compute_32", CudaVirtualArch::COMPUTE_32)
.Case("compute_35", CudaVirtualArch::COMPUTE_35)
.Case("compute_37", CudaVirtualArch::COMPUTE_37)
.Case("compute_50", CudaVirtualArch::COMPUTE_50)
.Case("compute_52", CudaVirtualArch::COMPUTE_52)
.Case("compute_53", CudaVirtualArch::COMPUTE_53)
.Case("compute_60", CudaVirtualArch::COMPUTE_60)
.Case("compute_61", CudaVirtualArch::COMPUTE_61)
.Case("compute_62", CudaVirtualArch::COMPUTE_62)
.Case("compute_70", CudaVirtualArch::COMPUTE_70)
.Default(CudaVirtualArch::UNKNOWN);
}
CudaVirtualArch VirtualArchForCudaArch(CudaArch A) {
switch (A) {
case CudaArch::UNKNOWN:
return CudaVirtualArch::UNKNOWN;
case CudaArch::SM_20:
case CudaArch::SM_21:
return CudaVirtualArch::COMPUTE_20;
case CudaArch::SM_30:
return CudaVirtualArch::COMPUTE_30;
case CudaArch::SM_32:
return CudaVirtualArch::COMPUTE_32;
case CudaArch::SM_35:
return CudaVirtualArch::COMPUTE_35;
case CudaArch::SM_37:
return CudaVirtualArch::COMPUTE_37;
case CudaArch::SM_50:
return CudaVirtualArch::COMPUTE_50;
case CudaArch::SM_52:
return CudaVirtualArch::COMPUTE_52;
case CudaArch::SM_53:
return CudaVirtualArch::COMPUTE_53;
case CudaArch::SM_60:
return CudaVirtualArch::COMPUTE_60;
case CudaArch::SM_61:
return CudaVirtualArch::COMPUTE_61;
case CudaArch::SM_62:
return CudaVirtualArch::COMPUTE_62;
case CudaArch::SM_70:
return CudaVirtualArch::COMPUTE_70;
}
llvm_unreachable("invalid enum");
}
CudaVersion MinVersionForCudaArch(CudaArch A) {
switch (A) {
case CudaArch::UNKNOWN:
return CudaVersion::UNKNOWN;
case CudaArch::SM_20:
case CudaArch::SM_21:
case CudaArch::SM_30:
case CudaArch::SM_32:
case CudaArch::SM_35:
case CudaArch::SM_37:
case CudaArch::SM_50:
case CudaArch::SM_52:
case CudaArch::SM_53:
return CudaVersion::CUDA_70;
case CudaArch::SM_60:
case CudaArch::SM_61:
case CudaArch::SM_62:
return CudaVersion::CUDA_80;
case CudaArch::SM_70:
return CudaVersion::CUDA_90;
}
llvm_unreachable("invalid enum");
}
CudaVersion MaxVersionForCudaArch(CudaArch A) {
switch (A) {
case CudaArch::UNKNOWN:
return CudaVersion::UNKNOWN;
case CudaArch::SM_20:
case CudaArch::SM_21:
return CudaVersion::CUDA_80;
default:
return CudaVersion::LATEST;
}
}
} // namespace clang

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
//===--- DiagnosticOptions.cpp - C Language Family Diagnostic Handling ----===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the DiagnosticOptions related interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/DiagnosticOptions.h"
#include "llvm/Support/raw_ostream.h"
namespace clang {
raw_ostream &operator<<(raw_ostream &Out, DiagnosticLevelMask M) {
using UT = std::underlying_type<DiagnosticLevelMask>::type;
return Out << static_cast<UT>(M);
}
} // end namespace clang

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,126 @@
//===--- FileSystemStatCache.cpp - Caching for 'stat' calls ---------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the FileSystemStatCache interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/FileSystemStatCache.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/Support/Path.h"
using namespace clang;
void FileSystemStatCache::anchor() { }
static void copyStatusToFileData(const vfs::Status &Status,
FileData &Data) {
Data.Name = Status.getName();
Data.Size = Status.getSize();
Data.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
Data.UniqueID = Status.getUniqueID();
Data.IsDirectory = Status.isDirectory();
Data.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;
Data.InPCH = false;
Data.IsVFSMapped = Status.IsVFSMapped;
}
/// FileSystemStatCache::get - Get the 'stat' information for the specified
/// path, using the cache to accelerate it if possible. This returns true if
/// the path does not exist or false if it exists.
///
/// If isFile is true, then this lookup should only return success for files
/// (not directories). If it is false this lookup should only return
/// success for directories (not files). On a successful file lookup, the
/// implementation can optionally fill in FileDescriptor with a valid
/// descriptor and the client guarantees that it will close it.
bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
FileSystemStatCache *Cache, vfs::FileSystem &FS) {
LookupResult R;
bool isForDir = !isFile;
// If we have a cache, use it to resolve the stat query.
if (Cache)
R = Cache->getStat(Path, Data, isFile, F, FS);
else if (isForDir || !F) {
// If this is a directory or a file descriptor is not needed and we have
// no cache, just go to the file system.
llvm::ErrorOr<vfs::Status> Status = FS.status(Path);
if (!Status) {
R = CacheMissing;
} else {
R = CacheExists;
copyStatusToFileData(*Status, Data);
}
} else {
// Otherwise, we have to go to the filesystem. We can always just use
// 'stat' here, but (for files) the client is asking whether the file exists
// because it wants to turn around and *open* it. It is more efficient to
// do "open+fstat" on success than it is to do "stat+open".
//
// Because of this, check to see if the file exists with 'open'. If the
// open succeeds, use fstat to get the stat info.
auto OwnedFile = FS.openFileForRead(Path);
if (!OwnedFile) {
// If the open fails, our "stat" fails.
R = CacheMissing;
} else {
// Otherwise, the open succeeded. Do an fstat to get the information
// about the file. We'll end up returning the open file descriptor to the
// client to do what they please with it.
llvm::ErrorOr<vfs::Status> Status = (*OwnedFile)->status();
if (Status) {
R = CacheExists;
copyStatusToFileData(*Status, Data);
*F = std::move(*OwnedFile);
} else {
// fstat rarely fails. If it does, claim the initial open didn't
// succeed.
R = CacheMissing;
*F = nullptr;
}
}
}
// If the path doesn't exist, return failure.
if (R == CacheMissing) return true;
// If the path exists, make sure that its "directoryness" matches the clients
// demands.
if (Data.IsDirectory != isForDir) {
// If not, close the file if opened.
if (F)
*F = nullptr;
return true;
}
return false;
}
MemorizeStatCalls::LookupResult
MemorizeStatCalls::getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) {
LookupResult Result = statChained(Path, Data, isFile, F, FS);
// Do not cache failed stats, it is easy to construct common inconsistent
// situations if we do, and they are not important for PCH performance (which
// currently only needs the stats to construct the initial FileManager
// entries).
if (Result == CacheMissing)
return Result;
// Cache file 'stat' results and directories with absolutely paths.
if (!Data.IsDirectory || llvm::sys::path::is_absolute(Path))
StatCalls[Path] = Data;
return Result;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
//===--- LangOptions.cpp - C Language Family Language Options ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the LangOptions class.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/StringRef.h"
using namespace clang;
LangOptions::LangOptions()
: IsHeaderFile(false) {
#define LANGOPT(Name, Bits, Default, Description) Name = Default;
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
#include "clang/Basic/LangOptions.def"
}
void LangOptions::resetNonModularOptions() {
#define LANGOPT(Name, Bits, Default, Description)
#define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default;
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
Name = Default;
#include "clang/Basic/LangOptions.def"
// These options do not affect AST generation.
SanitizerBlacklistFiles.clear();
XRayAlwaysInstrumentFiles.clear();
XRayNeverInstrumentFiles.clear();
CurrentModule.clear();
IsHeaderFile = false;
}
bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i)
if (FuncName.equals(NoBuiltinFuncs[i]))
return true;
return false;
}

View File

@ -0,0 +1,48 @@
//===- MemoryBufferCache.cpp - Cache for loaded memory buffers ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/MemoryBufferCache.h"
#include "llvm/Support/MemoryBuffer.h"
using namespace clang;
llvm::MemoryBuffer &
MemoryBufferCache::addBuffer(llvm::StringRef Filename,
std::unique_ptr<llvm::MemoryBuffer> Buffer) {
auto Insertion =
Buffers.insert({Filename, BufferEntry{std::move(Buffer), NextIndex++}});
assert(Insertion.second && "Already has a buffer");
return *Insertion.first->second.Buffer;
}
llvm::MemoryBuffer *MemoryBufferCache::lookupBuffer(llvm::StringRef Filename) {
auto I = Buffers.find(Filename);
if (I == Buffers.end())
return nullptr;
return I->second.Buffer.get();
}
bool MemoryBufferCache::isBufferFinal(llvm::StringRef Filename) {
auto I = Buffers.find(Filename);
if (I == Buffers.end())
return false;
return I->second.Index < FirstRemovableIndex;
}
bool MemoryBufferCache::tryToRemoveBuffer(llvm::StringRef Filename) {
auto I = Buffers.find(Filename);
assert(I != Buffers.end() && "No buffer to remove...");
if (I->second.Index < FirstRemovableIndex)
return true;
Buffers.erase(I);
return false;
}
void MemoryBufferCache::finalizeCurrentBuffers() { FirstRemovableIndex = NextIndex; }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
//===- ObjCRuntime.cpp - Objective-C Runtime Handling -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ObjCRuntime class, which represents the
// target Objective-C runtime.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/ObjCRuntime.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
std::string ObjCRuntime::getAsString() const {
std::string Result;
{
llvm::raw_string_ostream Out(Result);
Out << *this;
}
return Result;
}
raw_ostream &clang::operator<<(raw_ostream &out, const ObjCRuntime &value) {
switch (value.getKind()) {
case ObjCRuntime::MacOSX: out << "macosx"; break;
case ObjCRuntime::FragileMacOSX: out << "macosx-fragile"; break;
case ObjCRuntime::iOS: out << "ios"; break;
case ObjCRuntime::WatchOS: out << "watchos"; break;
case ObjCRuntime::GNUstep: out << "gnustep"; break;
case ObjCRuntime::GCC: out << "gcc"; break;
case ObjCRuntime::ObjFW: out << "objfw"; break;
}
if (value.getVersion() > VersionTuple(0)) {
out << '-' << value.getVersion();
}
return out;
}
bool ObjCRuntime::tryParse(StringRef input) {
// Look for the last dash.
std::size_t dash = input.rfind('-');
// We permit dashes in the runtime name, and we also permit the
// version to be omitted, so if we see a dash not followed by a
// digit then we need to ignore it.
if (dash != StringRef::npos && dash + 1 != input.size() &&
(input[dash+1] < '0' || input[dash+1] > '9')) {
dash = StringRef::npos;
}
// Everything prior to that must be a valid string name.
Kind kind;
StringRef runtimeName = input.substr(0, dash);
Version = VersionTuple(0);
if (runtimeName == "macosx") {
kind = ObjCRuntime::MacOSX;
} else if (runtimeName == "macosx-fragile") {
kind = ObjCRuntime::FragileMacOSX;
} else if (runtimeName == "ios") {
kind = ObjCRuntime::iOS;
} else if (runtimeName == "watchos") {
kind = ObjCRuntime::WatchOS;
} else if (runtimeName == "gnustep") {
// If no version is specified then default to the most recent one that we
// know about.
Version = VersionTuple(1, 6);
kind = ObjCRuntime::GNUstep;
} else if (runtimeName == "gcc") {
kind = ObjCRuntime::GCC;
} else if (runtimeName == "objfw") {
kind = ObjCRuntime::ObjFW;
Version = VersionTuple(0, 8);
} else {
return true;
}
TheKind = kind;
if (dash != StringRef::npos) {
StringRef verString = input.substr(dash + 1);
if (Version.tryParse(verString))
return true;
}
if (kind == ObjCRuntime::ObjFW && Version > VersionTuple(0, 8))
Version = VersionTuple(0, 8);
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
//===--- OperatorPrecedence.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Defines and computes precedence levels for binary/ternary operators.
///
//===----------------------------------------------------------------------===//
#include "clang/Basic/OperatorPrecedence.h"
namespace clang {
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
bool CPlusPlus11) {
switch (Kind) {
case tok::greater:
// C++ [temp.names]p3:
// [...] When parsing a template-argument-list, the first
// non-nested > is taken as the ending delimiter rather than a
// greater-than operator. [...]
if (GreaterThanIsOperator)
return prec::Relational;
return prec::Unknown;
case tok::greatergreater:
// C++11 [temp.names]p3:
//
// [...] Similarly, the first non-nested >> is treated as two
// consecutive but distinct > tokens, the first of which is
// taken as the end of the template-argument-list and completes
// the template-id. [...]
if (GreaterThanIsOperator || !CPlusPlus11)
return prec::Shift;
return prec::Unknown;
default: return prec::Unknown;
case tok::comma: return prec::Comma;
case tok::equal:
case tok::starequal:
case tok::slashequal:
case tok::percentequal:
case tok::plusequal:
case tok::minusequal:
case tok::lesslessequal:
case tok::greatergreaterequal:
case tok::ampequal:
case tok::caretequal:
case tok::pipeequal: return prec::Assignment;
case tok::question: return prec::Conditional;
case tok::pipepipe: return prec::LogicalOr;
case tok::caretcaret:
case tok::ampamp: return prec::LogicalAnd;
case tok::pipe: return prec::InclusiveOr;
case tok::caret: return prec::ExclusiveOr;
case tok::amp: return prec::And;
case tok::exclaimequal:
case tok::equalequal: return prec::Equality;
case tok::lessequal:
case tok::less:
case tok::greaterequal: return prec::Relational;
case tok::spaceship: return prec::Spaceship;
case tok::lessless: return prec::Shift;
case tok::plus:
case tok::minus: return prec::Additive;
case tok::percent:
case tok::slash:
case tok::star: return prec::Multiplicative;
case tok::periodstar:
case tok::arrowstar: return prec::PointerToMember;
}
}
} // namespace clang

View File

@ -0,0 +1,51 @@
//===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// User-provided blacklist used to disable/alter instrumentation done in
// sanitizers.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/SanitizerBlacklist.h"
using namespace clang;
SanitizerBlacklist::SanitizerBlacklist(
const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
: SSCL(SanitizerSpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {}
bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
StringRef GlobalName,
StringRef Category) const {
return SSCL->inSection(Mask, "global", GlobalName, Category);
}
bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask,
StringRef MangledTypeName,
StringRef Category) const {
return SSCL->inSection(Mask, "type", MangledTypeName, Category);
}
bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask,
StringRef FunctionName) const {
return SSCL->inSection(Mask, "fun", FunctionName);
}
bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask,
StringRef FileName,
StringRef Category) const {
return SSCL->inSection(Mask, "src", FileName, Category);
}
bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask,
SourceLocation Loc,
StringRef Category) const {
return Loc.isValid() &&
isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
}

View File

@ -0,0 +1,64 @@
//===--- SanitizerSpecialCaseList.cpp - SCL for sanitizers ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// An extension of SpecialCaseList to allowing querying sections by
// SanitizerMask.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/SanitizerSpecialCaseList.h"
using namespace clang;
std::unique_ptr<SanitizerSpecialCaseList>
SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
std::string &Error) {
std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
new SanitizerSpecialCaseList());
if (SSCL->createInternal(Paths, Error)) {
SSCL->createSanitizerSections();
return SSCL;
}
return nullptr;
}
std::unique_ptr<SanitizerSpecialCaseList>
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths) {
std::string Error;
if (auto SSCL = create(Paths, Error))
return SSCL;
llvm::report_fatal_error(Error);
}
void SanitizerSpecialCaseList::createSanitizerSections() {
for (auto &S : Sections) {
SanitizerMask Mask = 0;
#define SANITIZER(NAME, ID) \
if (S.SectionMatcher->match(NAME)) \
Mask |= SanitizerKind::ID;
#define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
#include "clang/Basic/Sanitizers.def"
#undef SANITIZER
#undef SANITIZER_GROUP
SanitizerSections.emplace_back(Mask, S.Entries);
}
}
bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
StringRef Query,
StringRef Category) const {
for (auto &S : SanitizerSections)
if ((S.Mask & Mask) &&
SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
return true;
return false;
}

View File

@ -0,0 +1,37 @@
//===--- Sanitizers.cpp - C Language Family Language Options ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the classes from Sanitizers.h
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) {
SanitizerMask ParsedKind = llvm::StringSwitch<SanitizerMask>(Value)
#define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID)
#define SANITIZER_GROUP(NAME, ID, ALIAS) \
.Case(NAME, AllowGroups ? SanitizerKind::ID##Group : 0)
#include "clang/Basic/Sanitizers.def"
.Default(0);
return ParsedKind;
}
SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) {
#define SANITIZER(NAME, ID)
#define SANITIZER_GROUP(NAME, ID, ALIAS) \
if (Kinds & SanitizerKind::ID##Group) \
Kinds |= SanitizerKind::ID;
#include "clang/Basic/Sanitizers.def"
return Kinds;
}

Some files were not shown because too many files have changed in this diff Show More