diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
commit | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch) | |
tree | 02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /utils | |
parent | c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff) | |
download | src-676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63.tar.gz src-676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63.zip |
Vendor import of clang trunk r351319 (just before the release_80 branchvendor/clang/clang-trunk-r351319
Notes
Notes:
svn path=/vendor/clang/dist/; revision=343173
svn path=/vendor/clang/clang-trunk-r351319/; revision=343174; tag=vendor/clang/clang-trunk-r351319
Diffstat (limited to 'utils')
29 files changed, 693 insertions, 789 deletions
diff --git a/utils/ABITest/ABITestGen.py b/utils/ABITest/ABITestGen.py index 27cc5ec25823..93a6de93068d 100755 --- a/utils/ABITest/ABITestGen.py +++ b/utils/ABITest/ABITestGen.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import absolute_import, division, print_function from pprint import pprint import random, atexit, time from random import randrange @@ -10,7 +11,7 @@ from TypeGen import * #### -class TypePrinter: +class TypePrinter(object): def __init__(self, output, outputHeader=None, outputTests=None, outputDriver=None, headerName=None, info=None): @@ -28,42 +29,42 @@ class TypePrinter: if info: for f in (self.output,self.outputHeader,self.outputTests,self.outputDriver): if f: - print >>f,info + print(info, file=f) if self.writeBody: - print >>self.output, '#include <stdio.h>\n' + print('#include <stdio.h>\n', file=self.output) if self.outputTests: - print >>self.outputTests, '#include <stdio.h>' - print >>self.outputTests, '#include <string.h>' - print >>self.outputTests, '#include <assert.h>\n' + print('#include <stdio.h>', file=self.outputTests) + print('#include <string.h>', file=self.outputTests) + print('#include <assert.h>\n', file=self.outputTests) if headerName: for f in (self.output,self.outputTests,self.outputDriver): if f is not None: - print >>f, '#include "%s"\n'%(headerName,) + print('#include "%s"\n'%(headerName,), file=f) if self.outputDriver: - print >>self.outputDriver, '#include <stdio.h>' - print >>self.outputDriver, '#include <stdlib.h>\n' - print >>self.outputDriver, 'int main(int argc, char **argv) {' - print >>self.outputDriver, ' int index = -1;' - print >>self.outputDriver, ' if (argc > 1) index = atoi(argv[1]);' + print('#include <stdio.h>', file=self.outputDriver) + print('#include <stdlib.h>\n', file=self.outputDriver) + print('int main(int argc, char **argv) {', file=self.outputDriver) + print(' int index = -1;', file=self.outputDriver) + print(' if (argc > 1) index = atoi(argv[1]);', file=self.outputDriver) def finish(self): if self.layoutTests: - print >>self.output, 'int main(int argc, char **argv) {' - print >>self.output, ' int index = -1;' - print >>self.output, ' if (argc > 1) index = atoi(argv[1]);' + print('int main(int argc, char **argv) {', file=self.output) + print(' int index = -1;', file=self.output) + print(' if (argc > 1) index = atoi(argv[1]);', file=self.output) for i,f in self.layoutTests: - print >>self.output, ' if (index == -1 || index == %d)' % i - print >>self.output, ' %s();' % f - print >>self.output, ' return 0;' - print >>self.output, '}' + print(' if (index == -1 || index == %d)' % i, file=self.output) + print(' %s();' % f, file=self.output) + print(' return 0;', file=self.output) + print('}', file=self.output) if self.outputDriver: - print >>self.outputDriver, ' printf("DONE\\n");' - print >>self.outputDriver, ' return 0;' - print >>self.outputDriver, '}' + print(' printf("DONE\\n");', file=self.outputDriver) + print(' return 0;', file=self.outputDriver) + print('}', file=self.outputDriver) def addDeclaration(self, decl): if decl in self.declarations: @@ -71,11 +72,11 @@ class TypePrinter: self.declarations.add(decl) if self.outputHeader: - print >>self.outputHeader, decl + print(decl, file=self.outputHeader) else: - print >>self.output, decl + print(decl, file=self.output) if self.outputTests: - print >>self.outputTests, decl + print(decl, file=self.outputTests) return True def getTypeName(self, T): @@ -91,12 +92,12 @@ class TypePrinter: tyNameClean = tyName.replace(' ','_').replace('*','star') fnName = 'test_%s' % tyNameClean - print >>self.output,'void %s(void) {' % fnName + print('void %s(void) {' % fnName, file=self.output) self.printSizeOfType(' %s'%fnName, tyName, ty, self.output) self.printAlignOfType(' %s'%fnName, tyName, ty, self.output) self.printOffsetsOfType(' %s'%fnName, tyName, ty, self.output) - print >>self.output,'}' - print >>self.output + print('}', file=self.output) + print(file=self.output) self.layoutTests.append((i,fnName)) @@ -115,71 +116,71 @@ class TypePrinter: fnName = 'fn%d'%(FT.index,) if self.outputHeader: - print >>self.outputHeader,'%s %s(%s);'%(retvalTypeName, fnName, args) + print('%s %s(%s);'%(retvalTypeName, fnName, args), file=self.outputHeader) elif self.outputTests: - print >>self.outputTests,'%s %s(%s);'%(retvalTypeName, fnName, args) + print('%s %s(%s);'%(retvalTypeName, fnName, args), file=self.outputTests) - print >>self.output,'%s %s(%s)'%(retvalTypeName, fnName, args), + print('%s %s(%s)'%(retvalTypeName, fnName, args), end=' ', file=self.output) if self.writeBody: - print >>self.output, '{' + print('{', file=self.output) for i,t in enumerate(FT.argTypes): self.printValueOfType(' %s'%fnName, 'arg%d'%i, t) if retvalName is not None: - print >>self.output, ' return %s;'%(retvalName,) - print >>self.output, '}' + print(' return %s;'%(retvalName,), file=self.output) + print('}', file=self.output) else: - print >>self.output, '{}' - print >>self.output + print('{}', file=self.output) + print(file=self.output) if self.outputDriver: - print >>self.outputDriver, ' if (index == -1 || index == %d) {' % i - print >>self.outputDriver, ' extern void test_%s(void);' % fnName - print >>self.outputDriver, ' test_%s();' % fnName - print >>self.outputDriver, ' }' + print(' if (index == -1 || index == %d) {' % i, file=self.outputDriver) + print(' extern void test_%s(void);' % fnName, file=self.outputDriver) + print(' test_%s();' % fnName, file=self.outputDriver) + print(' }', file=self.outputDriver) if self.outputTests: if self.outputHeader: - print >>self.outputHeader, 'void test_%s(void);'%(fnName,) + print('void test_%s(void);'%(fnName,), file=self.outputHeader) if retvalName is None: retvalTests = None else: retvalTests = self.getTestValuesArray(FT.returnType) - tests = map(self.getTestValuesArray, FT.argTypes) - print >>self.outputTests, 'void test_%s(void) {'%(fnName,) + tests = [self.getTestValuesArray(ty) for ty in FT.argTypes] + print('void test_%s(void) {'%(fnName,), file=self.outputTests) if retvalTests is not None: - print >>self.outputTests, ' printf("%s: testing return.\\n");'%(fnName,) - print >>self.outputTests, ' for (int i=0; i<%d; ++i) {'%(retvalTests[1],) + print(' printf("%s: testing return.\\n");'%(fnName,), file=self.outputTests) + print(' for (int i=0; i<%d; ++i) {'%(retvalTests[1],), file=self.outputTests) args = ', '.join(['%s[%d]'%(t,randrange(l)) for t,l in tests]) - print >>self.outputTests, ' %s RV;'%(retvalTypeName,) - print >>self.outputTests, ' %s = %s[i];'%(retvalName, retvalTests[0]) - print >>self.outputTests, ' RV = %s(%s);'%(fnName, args) + print(' %s RV;'%(retvalTypeName,), file=self.outputTests) + print(' %s = %s[i];'%(retvalName, retvalTests[0]), file=self.outputTests) + print(' RV = %s(%s);'%(fnName, args), file=self.outputTests) self.printValueOfType(' %s_RV'%fnName, 'RV', FT.returnType, output=self.outputTests, indent=4) self.checkTypeValues('RV', '%s[i]' % retvalTests[0], FT.returnType, output=self.outputTests, indent=4) - print >>self.outputTests, ' }' + print(' }', file=self.outputTests) if tests: - print >>self.outputTests, ' printf("%s: testing arguments.\\n");'%(fnName,) + print(' printf("%s: testing arguments.\\n");'%(fnName,), file=self.outputTests) for i,(array,length) in enumerate(tests): for j in range(length): args = ['%s[%d]'%(t,randrange(l)) for t,l in tests] args[i] = '%s[%d]'%(array,j) - print >>self.outputTests, ' %s(%s);'%(fnName, ', '.join(args),) - print >>self.outputTests, '}' + print(' %s(%s);'%(fnName, ', '.join(args),), file=self.outputTests) + print('}', file=self.outputTests) def getTestReturnValue(self, type): typeName = self.getTypeName(type) info = self.testReturnValues.get(typeName) if info is None: name = '%s_retval'%(typeName.replace(' ','_').replace('*','star'),) - print >>self.output, '%s %s;'%(typeName,name) + print('%s %s;'%(typeName,name), file=self.output) if self.outputHeader: - print >>self.outputHeader, 'extern %s %s;'%(typeName,name) + print('extern %s %s;'%(typeName,name), file=self.outputHeader) elif self.outputTests: - print >>self.outputTests, 'extern %s %s;'%(typeName,name) + print('extern %s %s;'%(typeName,name), file=self.outputTests) info = self.testReturnValues[typeName] = name return info @@ -188,12 +189,12 @@ class TypePrinter: info = self.testValues.get(typeName) if info is None: name = '%s_values'%(typeName.replace(' ','_').replace('*','star'),) - print >>self.outputTests, 'static %s %s[] = {'%(typeName,name) + print('static %s %s[] = {'%(typeName,name), file=self.outputTests) length = 0 for item in self.getTestValues(type): - print >>self.outputTests, '\t%s,'%(item,) + print('\t%s,'%(item,), file=self.outputTests) length += 1 - print >>self.outputTests,'};' + print('};', file=self.outputTests) info = self.testValues[typeName] = (name,length) return info @@ -230,10 +231,10 @@ class TypePrinter: yield '{ %s }' % v return - fieldValues = map(list, map(self.getTestValues, nonPadding)) + fieldValues = [list(v) for v in map(self.getTestValues, nonPadding)] for i,values in enumerate(fieldValues): for v in values: - elements = map(random.choice,fieldValues) + elements = [random.choice(fv) for fv in fieldValues] elements[i] = v yield '{ %s }'%(', '.join(elements)) @@ -250,19 +251,19 @@ class TypePrinter: elements[i] = v yield '{ %s }'%(', '.join(elements)) else: - raise NotImplementedError,'Cannot make tests values of type: "%s"'%(t,) + raise NotImplementedError('Cannot make tests values of type: "%s"'%(t,)) def printSizeOfType(self, prefix, name, t, output=None, indent=2): - print >>output, '%*sprintf("%s: sizeof(%s) = %%ld\\n", (long)sizeof(%s));'%(indent, '', prefix, name, name) + print('%*sprintf("%s: sizeof(%s) = %%ld\\n", (long)sizeof(%s));'%(indent, '', prefix, name, name), file=output) def printAlignOfType(self, prefix, name, t, output=None, indent=2): - print >>output, '%*sprintf("%s: __alignof__(%s) = %%ld\\n", (long)__alignof__(%s));'%(indent, '', prefix, name, name) + print('%*sprintf("%s: __alignof__(%s) = %%ld\\n", (long)__alignof__(%s));'%(indent, '', prefix, name, name), file=output) def printOffsetsOfType(self, prefix, name, t, output=None, indent=2): if isinstance(t, RecordType): for i,f in enumerate(t.fields): if f.isBitField(): continue fname = 'field%d' % i - print >>output, '%*sprintf("%s: __builtin_offsetof(%s, %s) = %%ld\\n", (long)__builtin_offsetof(%s, %s));'%(indent, '', prefix, name, fname, name, fname) + print('%*sprintf("%s: __builtin_offsetof(%s, %s) = %%ld\\n", (long)__builtin_offsetof(%s, %s));'%(indent, '', prefix, name, fname, name, fname), file=output) def printValueOfType(self, prefix, name, t, output=None, indent=2): if output is None: @@ -286,13 +287,13 @@ class TypePrinter: code = 'Lf' else: code = 'p' - print >>output, '%*sprintf("%s: %s = %%%s\\n", %s);'%( - indent, '', prefix, name, code, value_expr) + print('%*sprintf("%s: %s = %%%s\\n", %s);'%( + indent, '', prefix, name, code, value_expr), file=output) elif isinstance(t, EnumType): - print >>output, '%*sprintf("%s: %s = %%d\\n", %s);'%(indent, '', prefix, name, name) + print('%*sprintf("%s: %s = %%d\\n", %s);'%(indent, '', prefix, name, name), file=output) elif isinstance(t, RecordType): if not t.fields: - print >>output, '%*sprintf("%s: %s (empty)\\n");'%(indent, '', prefix, name) + print('%*sprintf("%s: %s (empty)\\n");'%(indent, '', prefix, name), file=output) for i,f in enumerate(t.fields): if f.isPaddingBitField(): continue @@ -310,16 +311,16 @@ class TypePrinter: else: self.printValueOfType(prefix, '%s[%d]'%(name,i), t.elementType, output=output,indent=indent) else: - raise NotImplementedError,'Cannot print value of type: "%s"'%(t,) + raise NotImplementedError('Cannot print value of type: "%s"'%(t,)) def checkTypeValues(self, nameLHS, nameRHS, t, output=None, indent=2): prefix = 'foo' if output is None: output = self.output if isinstance(t, BuiltinType): - print >>output, '%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS) + print('%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS), file=output) elif isinstance(t, EnumType): - print >>output, '%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS) + print('%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS), file=output) elif isinstance(t, RecordType): for i,f in enumerate(t.fields): if f.isPaddingBitField(): @@ -343,7 +344,7 @@ class TypePrinter: self.checkTypeValues('%s[%d]'%(nameLHS,i), '%s[%d]'%(nameRHS,i), t.elementType, output=output,indent=indent) else: - raise NotImplementedError,'Cannot print value of type: "%s"'%(t,) + raise NotImplementedError('Cannot print value of type: "%s"'%(t,)) import sys @@ -642,9 +643,9 @@ def main(): def write(N): try: FT = ftg.get(N) - except RuntimeError,e: + except RuntimeError as e: if e.args[0]=='maximum recursion depth exceeded': - print >>sys.stderr,'WARNING: Skipped %d, recursion limit exceeded (bad arguments?)'%(N,) + print('WARNING: Skipped %d, recursion limit exceeded (bad arguments?)'%(N,), file=sys.stderr) return raise if opts.testLayout: diff --git a/utils/ABITest/Enumeration.py b/utils/ABITest/Enumeration.py index 47e47026db08..24f5b5fba24c 100644 --- a/utils/ABITest/Enumeration.py +++ b/utils/ABITest/Enumeration.py @@ -1,5 +1,6 @@ """Utilities for enumeration of finite and countably infinite sets. """ +from __future__ import absolute_import, division, print_function ### # Countable iteration @@ -17,7 +18,7 @@ class Aleph0(int): return 1 def __sub__(self, b): - raise ValueError,"Cannot subtract aleph0" + raise ValueError("Cannot subtract aleph0") __rsub__ = __sub__ def __add__(self, b): @@ -46,7 +47,8 @@ aleph0 = Aleph0() def base(line): return line*(line+1)//2 -def pairToN((x,y)): +def pairToN(pair): + x,y = pair line,index = x+y,y return base(line)+index @@ -86,9 +88,9 @@ def getNthPairBounded(N,W=aleph0,H=aleph0,useDivmod=False): Return the N-th pair such that 0 <= x < W and 0 <= y < H.""" if W <= 0 or H <= 0: - raise ValueError,"Invalid bounds" + raise ValueError("Invalid bounds") elif N >= W*H: - raise ValueError,"Invalid input (out of bounds)" + raise ValueError("Invalid input (out of bounds)") # Simple case... if W is aleph0 and H is aleph0: @@ -170,7 +172,7 @@ def getNthTuple(N, maxSize=aleph0, maxElement=aleph0, useDivmod=False, useLeftTo N -= 1 if maxElement is not aleph0: if maxSize is aleph0: - raise NotImplementedError,'Max element size without max size unhandled' + raise NotImplementedError('Max element size without max size unhandled') bounds = [maxElement**i for i in range(1, maxSize+1)] S,M = getNthPairVariableBounds(N, bounds) else: @@ -193,12 +195,12 @@ def getNthPairVariableBounds(N, bounds): bounds[x].""" if not bounds: - raise ValueError,"Invalid bounds" + raise ValueError("Invalid bounds") if not (0 <= N < sum(bounds)): - raise ValueError,"Invalid input (out of bounds)" + raise ValueError("Invalid input (out of bounds)") level = 0 - active = range(len(bounds)) + active = list(range(len(bounds))) active.sort(key=lambda i: bounds[i]) prevLevel = 0 for i,index in enumerate(active): @@ -216,7 +218,7 @@ def getNthPairVariableBounds(N, bounds): N -= levelSize prevLevel = level else: - raise RuntimError,"Unexpected loop completion" + raise RuntimError("Unexpected loop completion") def getNthPairVariableBoundsChecked(N, bounds, GNVP=getNthPairVariableBounds): x,y = GNVP(N,bounds) @@ -233,18 +235,18 @@ def testPairs(): for i in range(min(W*H,40)): x,y = getNthPairBounded(i,W,H) x2,y2 = getNthPairBounded(i,W,H,useDivmod=True) - print i,(x,y),(x2,y2) + print(i,(x,y),(x2,y2)) a[y][x] = '%2d'%i b[y2][x2] = '%2d'%i - print '-- a --' + print('-- a --') for ln in a[::-1]: if ''.join(ln).strip(): - print ' '.join(ln) - print '-- b --' + print(' '.join(ln)) + print('-- b --') for ln in b[::-1]: if ''.join(ln).strip(): - print ' '.join(ln) + print(' '.join(ln)) def testPairsVB(): bounds = [2,2,4,aleph0,5,aleph0] @@ -252,13 +254,13 @@ def testPairsVB(): b = [[' ' for x in range(15)] for y in range(15)] for i in range(min(sum(bounds),40)): x,y = getNthPairVariableBounds(i, bounds) - print i,(x,y) + print(i,(x,y)) a[y][x] = '%2d'%i - print '-- a --' + print('-- a --') for ln in a[::-1]: if ''.join(ln).strip(): - print ' '.join(ln) + print(' '.join(ln)) ### diff --git a/utils/ABITest/TypeGen.py b/utils/ABITest/TypeGen.py index 1e4471c71e57..8561baea617b 100644 --- a/utils/ABITest/TypeGen.py +++ b/utils/ABITest/TypeGen.py @@ -1,4 +1,5 @@ """Flexible enumeration of C types.""" +from __future__ import division, print_function from Enumeration import * @@ -17,7 +18,7 @@ from Enumeration import * ### # Actual type types -class Type: +class Type(object): def isBitField(self): return False @@ -99,7 +100,8 @@ class RecordType(Type): ' '.join(map(getField, self.fields))) def getTypedefDef(self, name, printer): - def getField((i, t)): + def getField(it): + i, t = it if t.isBitField(): if t.isPaddingBitField(): return '%s : 0;'%(printer.getTypeName(t),) @@ -108,7 +110,7 @@ class RecordType(Type): t.getBitFieldSize()) else: return '%s field%d;'%(printer.getTypeName(t),i) - fields = map(getField, enumerate(self.fields)) + fields = [getField(f) for f in enumerate(self.fields)] # Name the struct for more readable LLVM IR. return 'typedef %s %s { %s } %s;'%(('struct','union')[self.isUnion], name, ' '.join(fields), name) @@ -233,7 +235,7 @@ def fact(n): # Compute the number of combinations (n choose k) def num_combinations(n, k): - return fact(n) / (fact(k) * fact(n - k)) + return fact(n) // (fact(k) * fact(n - k)) # Enumerate the combinations choosing k elements from the list of values def combinations(values, k): @@ -241,7 +243,7 @@ def combinations(values, k): # combinations, selections of a sequence if k==0: yield [] else: - for i in xrange(len(values)-k+1): + for i in range(len(values)-k+1): for cc in combinations(values[i+1:],k-1): yield [values[i]]+cc @@ -370,7 +372,7 @@ class RecordTypeGenerator(TypeGenerator): isUnion,I = False,N if self.useUnion: isUnion,I = (I&1),I>>1 - fields = map(self.typeGen.get,getNthTuple(I,self.maxSize,self.typeGen.cardinality)) + fields = [self.typeGen.get(f) for f in getNthTuple(I,self.maxSize,self.typeGen.cardinality)] return RecordType(N, isUnion, fields) class FunctionTypeGenerator(TypeGenerator): @@ -403,7 +405,7 @@ class FunctionTypeGenerator(TypeGenerator): else: retTy = None argIndices = getNthTuple(N, self.maxSize, self.typeGen.cardinality) - args = map(self.typeGen.get, argIndices) + args = [self.typeGen.get(i) for i in argIndices] return FunctionType(N, retTy, args) class AnyTypeGenerator(TypeGenerator): @@ -435,7 +437,7 @@ class AnyTypeGenerator(TypeGenerator): if (self._cardinality is aleph0) or prev==self._cardinality: break else: - raise RuntimeError,"Infinite loop in setting cardinality" + raise RuntimeError("Infinite loop in setting cardinality") def generateType(self, N): index,M = getNthPairVariableBounds(N, self.bounds) @@ -461,15 +463,15 @@ def test(): atg.addGenerator( btg ) atg.addGenerator( RecordTypeGenerator(fields0, False, 4) ) atg.addGenerator( etg ) - print 'Cardinality:',atg.cardinality + print('Cardinality:',atg.cardinality) for i in range(100): if i == atg.cardinality: try: atg.get(i) - raise RuntimeError,"Cardinality was wrong" + raise RuntimeError("Cardinality was wrong") except AssertionError: break - print '%4d: %s'%(i, atg.get(i)) + print('%4d: %s'%(i, atg.get(i))) if __name__ == '__main__': test() diff --git a/utils/CIndex/completion_logger_server.py b/utils/CIndex/completion_logger_server.py index 0652b1f4a8ee..201667117fc2 100755 --- a/utils/CIndex/completion_logger_server.py +++ b/utils/CIndex/completion_logger_server.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import, division, print_function import sys from socket import * from time import strftime @@ -6,7 +7,7 @@ import datetime def main(): if len(sys.argv) < 4: - print "completion_logger_server.py <listen address> <listen port> <log file>" + print("completion_logger_server.py <listen address> <listen port> <log file>") exit(1) host = sys.argv[1] @@ -18,7 +19,7 @@ def main(): UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(addr) - print "Listing on {0}:{1} and logging to '{2}'".format(host, port, sys.argv[3]) + print("Listing on {0}:{1} and logging to '{2}'".format(host, port, sys.argv[3])) # Open the logging file. f = open(sys.argv[3], "a") diff --git a/utils/ClangVisualizers/clang.natvis b/utils/ClangVisualizers/clang.natvis index 6e3ca96ffde3..17556f9cabb1 100644 --- a/utils/ClangVisualizers/clang.natvis +++ b/utils/ClangVisualizers/clang.natvis @@ -34,15 +34,35 @@ For later versions of Visual Studio, no setup is required--> <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Record" IncludeView="cpp">{*(clang::RecordType *)this,view(cpp)}</DisplayString>
<DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::FunctionProto" IncludeView="poly">{*(clang::FunctionProtoType *)this}</DisplayString>
<DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::TemplateSpecialization" IncludeView="poly">{*(clang::TemplateSpecializationType *)this}</DisplayString>
+ <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::DeducedTemplateSpecialization" IncludeView="poly">{*(clang::DeducedTemplateSpecializationType *)this}</DisplayString>
<DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::InjectedClassName" IncludeView="poly">{*(clang::InjectedClassNameType *)this}</DisplayString>
<DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::PackExpansion" IncludeView="poly">{*(clang::PackExpansionType *)this}</DisplayString>
<DisplayString Condition="TypeBits.TC==clang::LocInfoType::LocInfo" IncludeView="poly">{*(clang::LocInfoType *)this}</DisplayString>
<DisplayString IncludeView="cpp">{*this,view(poly)}</DisplayString>
- <DisplayString IncludeView="poly">{*this,view(cmn)}</DisplayString> <!-- Not yet implemented Type subclass -->
+ <DisplayString IncludeView="poly">No visualizer yet for {(clang::Type::TypeClass)TypeBits.TC,en}Type</DisplayString> <!-- Not yet implemented Type subclass -->
+ <DisplayString IncludeView="Dependent" Condition="TypeBits.Dependent">Dependent{" ",sb}</DisplayString>
+ <DisplayString IncludeView="Dependent"></DisplayString>
+ <DisplayString IncludeView="InstantiationDependent" Condition="TypeBits.InstantiationDependent">InstantiationDependent{" ",sb}</DisplayString>
+ <DisplayString IncludeView="InstantiationDependent"></DisplayString>
+ <DisplayString IncludeView="VariablyModified" Condition="TypeBits.VariablyModified">VariablyModified{" ",sb}</DisplayString>
+ <DisplayString IncludeView="VariablyModified"></DisplayString>
+ <DisplayString IncludeView="ContainsUnexpandedParameterPack" Condition="TypeBits.ContainsUnexpandedParameterPack">ContainsUnexpandedParameterPack{" ",sb}</DisplayString>
+ <DisplayString IncludeView="ContainsUnexpandedParameterPack"></DisplayString>
+ <DisplayString IncludeView="Cache" Condition="TypeBits.CacheValid && TypeBits.CachedLocalOrUnnamed">CachedLinkage: {(clang::Linkage)TypeBits.CachedLinkage,en} CachedLocalOrUnnamed</DisplayString>
+ <DisplayString IncludeView="Cache" Condition="TypeBits.CacheValid && !TypeBits.CachedLocalOrUnnamed">CachedLinkage: {(clang::Linkage)TypeBits.CachedLinkage,en}{" ",sb}</DisplayString>
+ <DisplayString IncludeView="Cache"></DisplayString>
+ <DisplayString IncludeView="FromAST" Condition="TypeBits.FromAST">FromAST</DisplayString>
+ <DisplayString IncludeView="FromAST"></DisplayString>
+ <DisplayString IncludeView="flags" Condition="!TypeBits.Dependent && !TypeBits.InstantiationDependent && !TypeBits.VariablyModified && !TypeBits.ContainsUnexpandedParameterPack && !TypeBits.CacheValid && !TypeBits.FromAST">
+ No TypeBits set beyond TypeClass
+ </DisplayString>
+ <DisplayString IncludeView="flags">
+{*this, view(Dependent)}{*this, view(InstantiationDependent)}{*this, view(VariablyModified)}
+{*this, view(ContainsUnexpandedParameterPack)}{*this, view(Cache)}{*this, view(FromAST)}</DisplayString>
<DisplayString>{*this,view(cmn)} {{{*this,view(poly)}}}</DisplayString>
<Expand>
<Item Name="TypeClass" IncludeView="cmn">(clang::Type::TypeClass)TypeBits.TC</Item>
- <Item Name="Flags" IncludeView="cmn">TypeBits</Item>
+ <Item Name="Flags" IncludeView="cmn">*this,view(flags)</Item>
<Item Name="Canonical" IncludeView="cmn">CanonicalType</Item>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">*(clang::BuiltinType *)this</ExpandedItem>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Pointer">*(clang::PointerType *)this</ExpandedItem>
@@ -54,6 +74,7 @@ For later versions of Visual Studio, no setup is required--> <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Record">(clang::RecordType *)this</ExpandedItem>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::FunctionProto">(clang::FunctionProtoType *)this</ExpandedItem>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::TemplateSpecialization">(clang::TemplateSpecializationType *)this</ExpandedItem>
+ <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::DeducedTemplateSpecialization">(clang::DeducedTemplateSpecializationType *)this</ExpandedItem>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::InjectedClassName">(clang::InjectedClassNameType *)this</ExpandedItem>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::PackExpansion">(clang::PackExpansionType *)this</ExpandedItem>
<ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::LocInfoType::LocInfo">(clang::LocInfoType *)this</ExpandedItem>
@@ -120,12 +141,19 @@ For later versions of Visual Studio, no setup is required--> <Type Name="clang::TemplateTypeParmDecl">
<DisplayString IncludeView="TorC" Condition="Typename">typename</DisplayString>
<DisplayString IncludeView="TorC" Condition="!Typename">class</DisplayString>
- <DisplayString IncludeView="MaybeEllipses" Condition="((TemplateTypeParmType *)TypeForDecl)->CanTTPTInfo.ParameterPack">...</DisplayString>
- <DisplayString IncludeView="MaybeEllipses" Condition="!((TemplateTypeParmType *)TypeForDecl)->CanTTPTInfo.ParameterPack"></DisplayString>
+ <DisplayString IncludeView="MaybeEllipses" Condition="TypeForDecl == nullptr">(not yet known if parameter pack) </DisplayString>
+ <DisplayString IncludeView="MaybeEllipses" Condition="((TemplateTypeParmType *)(((clang::ExtQualsTypeCommonBase *)(((uintptr_t)TypeForDecl->CanonicalType.Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType))->CanTTPTInfo.ParameterPack">...</DisplayString>
+ <DisplayString IncludeView="MaybeEllipses" Condition="!((TemplateTypeParmType *)(((clang::ExtQualsTypeCommonBase *)(((uintptr_t)TypeForDecl->CanonicalType.Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType))->CanTTPTInfo.ParameterPack"></DisplayString>
<DisplayString>{*this,view(TorC)} {*this,view(MaybeEllipses)}{Name,view(cpp)}</DisplayString>
</Type>
<Type Name="clang::TemplateDecl">
- <DisplayString>template{*TemplateParams} {*TemplatedDecl};</DisplayString>
+ <DisplayString>template{TemplateParams,view(deref)} {*TemplatedDecl};</DisplayString>
+ </Type>
+ <Type Name="clang::TemplateName">
+ <DisplayString>{Storage,view(deref)}</DisplayString>
+ <Expand>
+ <ExpandedItem>Storage</ExpandedItem>
+ </Expand>
</Type>
<Type Name="clang::NamedDecl" >
<DisplayString IncludeView="cpp">{Name,view(cpp)}</DisplayString>
@@ -134,13 +162,13 @@ For later versions of Visual Studio, no setup is required--> <Type Name="clang::TagDecl">
<DisplayString IncludeView="implicit" Condition="Implicit">implicit{" ",sb}</DisplayString>
<DisplayString IncludeView="implicit"></DisplayString>
- <DisplayString IncludeView="modifiers">{*this,view(implicit)}</DisplayString>
+ <DisplayString IncludeView="modifiers">{*this,view(implicit)nd}</DisplayString>
<DisplayString IncludeView="cpp">{*this,view(modifiers)}{Name,view(cpp)}</DisplayString>
- <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Struct">{*this,view(modifiers)}struct {Name,view(cpp)}</DisplayString>
- <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Interface">{*this,view(modifiers)}interface {Name,view(cpp)}</DisplayString>
- <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Union">{*this,view(modifiers)}union {Name,view(cpp)}</DisplayString>
- <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Class">{*this,view(modifiers)}class {Name,view(cpp)}</DisplayString>
- <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Enum">{*this,view(modifiers)}enum {Name,view(cpp)}</DisplayString>
+ <DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Struct">{*this,view(modifiers)nd}struct {Name,view(cpp)}</DisplayString>
+ <DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Interface">{*this,view(modifiers)nd}interface {Name,view(cpp)}</DisplayString>
+ <DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Union">{*this,view(modifiers)nd}union {Name,view(cpp)}</DisplayString>
+ <DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Class">{*this,view(modifiers)nd}class {Name,view(cpp)}</DisplayString>
+ <DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Enum">{*this,view(modifiers)nd}enum {Name,view(cpp)}</DisplayString>
<Expand>
<ExpandedItem>(clang::DeclContext *)this</ExpandedItem>
</Expand>
@@ -171,17 +199,17 @@ For later versions of Visual Studio, no setup is required--> but the expansion has all parameters -->
<Type Name="clang::FunctionProtoType">
<DisplayString IncludeView="retType">{ResultType,view(cpp)}</DisplayString>
- <DisplayString IncludeView="parm0" Condition="NumParams==0"></DisplayString>
+ <DisplayString IncludeView="parm0" Condition="FunctionTypeBits.NumParams==0"></DisplayString>
<DisplayString IncludeView="parm0">{*(clang::QualType *)(this+1),view(cpp)}{*this,view(parm1)}</DisplayString>
- <DisplayString IncludeView="parm1" Condition="NumParams==1"></DisplayString>
+ <DisplayString IncludeView="parm1" Condition="FunctionTypeBits.NumParams==1"></DisplayString>
<DisplayString IncludeView="parm1">, {*((clang::QualType *)(this+1)+1),view(cpp)}{*this,view(parm2)}</DisplayString>
- <DisplayString IncludeView="parm2" Condition="NumParams==2"></DisplayString>
+ <DisplayString IncludeView="parm2" Condition="FunctionTypeBits.NumParams==2"></DisplayString>
<DisplayString IncludeView="parm2">, {*((clang::QualType *)(this+1)+2),view(cpp)}{*this,view(parm3)}</DisplayString>
- <DisplayString IncludeView="parm3" Condition="NumParams==3"></DisplayString>
+ <DisplayString IncludeView="parm3" Condition="FunctionTypeBits.NumParams==3"></DisplayString>
<DisplayString IncludeView="parm3">, {*((clang::QualType *)(this+1)+3),view(cpp)}{*this,view(parm4)}</DisplayString>
- <DisplayString IncludeView="parm4" Condition="NumParams==4"></DisplayString>
+ <DisplayString IncludeView="parm4" Condition="FunctionTypeBits.NumParams==4"></DisplayString>
<DisplayString IncludeView="parm4">, {*((clang::QualType *)(this+1)+4),view(cpp)}{*this,view(parm5)}</DisplayString>
- <DisplayString IncludeView="parm5" Condition="NumParams==5"></DisplayString>
+ <DisplayString IncludeView="parm5" Condition="FunctionTypeBits.NumParams==5"></DisplayString>
<DisplayString IncludeView="parm5">, /* expand for more params */</DisplayString>
<DisplayString>{*this,view(retType)}({*this,view(parm0)})</DisplayString>
<Expand>
@@ -190,7 +218,7 @@ For later versions of Visual Studio, no setup is required--> <DisplayString>{*this,view(parm0)}</DisplayString>
<Expand>
<ArrayItems>
- <Size>NumParams</Size>
+ <Size>FunctionTypeBits.NumParams</Size>
<ValuePointer>(clang::QualType *)(this+1)</ValuePointer>
</ArrayItems>
</Expand>
@@ -199,8 +227,11 @@ For later versions of Visual Studio, no setup is required--> </Expand>
</Type>
<Type Name="clang::TemplateTypeParmType">
- <DisplayString IncludeView="cpp">{*TTPDecl,view(cpp)}</DisplayString>
- <DisplayString>{*TTPDecl}</DisplayString>
+ <DisplayString IncludeView="cpp" Condition="CanonicalType.Value.Value != this">{*TTPDecl}</DisplayString>
+ <DisplayString Condition="CanonicalType.Value.Value != this">Non-canonical: {*TTPDecl}</DisplayString>
+ <DisplayString>Canonical: {CanTTPTInfo}</DisplayString>
+ <Expand>
+ </Expand>
</Type>
<Type Name="clang::InjectedClassNameType">
<DisplayString>{*Decl,view(cpp)}</DisplayString>
@@ -233,10 +264,11 @@ For later versions of Visual Studio, no setup is required--> <DisplayString IncludeView="fastQuals" Condition="(Value.Value & 15)==6">{" ",sb}volatile restrict</DisplayString>
<DisplayString IncludeView="fastQuals" Condition="(Value.Value & 15)==7">{" ",sb}const volatile restrict</DisplayString>
<DisplayString IncludeView="fastQuals">Cannot visualize non-fast qualifiers</DisplayString>
+ <DisplayString Condition="(uintptr_t)Value.Value == 0">Null</DisplayString>
<DisplayString>{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType}{*this,view(fastQuals)}</DisplayString>
<Expand>
<Item Name="Fast Quals">*this,view(fastQuals)</Item>
- <Item Name="BaseType">*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType</Item>
+ <ExpandedItem>*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType</ExpandedItem>
</Expand>
</Type>
<Type Name="clang::LocInfoType">
@@ -381,6 +413,29 @@ For later versions of Visual Studio, no setup is required--> </ArrayItems>
</Expand>
</Type>
+ <Type Name="clang::DeducedType">
+ <Expand>
+ <Item Name="isDeduced">(CanonicalType.Value.Value != this) || TypeBits.Dependent</Item>
+ <ExpandedItem>*(clang::Type *)this,view(cmn)</ExpandedItem>
+ </Expand>
+ </Type>
+ <Type Name="clang::DeducedTemplateSpecializationType">
+ <DisplayString Condition="(CanonicalType.Value.Value != this) || TypeBits.Dependent">{CanonicalType,view(cpp)}</DisplayString>
+ <DisplayString>{Template}</DisplayString>
+ <Expand>
+ <Item Name="Template">Template</Item>
+ <Item Name="Deduced As" Condition="(CanonicalType.Value.Value != this) || TypeBits.Dependent">CanonicalType,view(cpp)</Item>
+ <ExpandedItem>*(clang::DeducedType *)this</ExpandedItem>
+ <Item Name="Template">Template</Item>
+ </Expand>
+ </Type>
+ <Type Name="clang::ClassTemplateSpecializationDecl">
+ <DisplayString>{*(CXXRecordDecl *)this,nd}{*TemplateArgs}</DisplayString>
+ <Expand>
+ <ExpandedItem>(CXXRecordDecl *)this,nd</ExpandedItem>
+ <Item Name="TemplateArgs">TemplateArgs</Item>
+ </Expand>
+ </Type>
<Type Name="clang::IdentifierInfo">
<DisplayString Condition="Entry != 0">{((llvm::StringMapEntry<clang::IdentifierInfo *>*)Entry)+1,sb}</DisplayString>
<Expand>
@@ -395,22 +450,29 @@ For later versions of Visual Studio, no setup is required--> <DisplayString Condition="(Ptr & PtrMask) == StoredIdentifier">{{Identifier ({*(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}</DisplayString>
<DisplayString Condition="(Ptr & PtrMask) == StoredObjCZeroArgSelector">{{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}</DisplayString>
<DisplayString Condition="(Ptr & PtrMask) == StoredObjCOneArgSelector">{{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}</DisplayString>
+ <DisplayString Condition="(Ptr & PtrMask) == StoredCXXConstructorName">C++ Constructor {{*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}}</DisplayString>
+ <DisplayString Condition="(Ptr & PtrMask) == StoredCXXDestructorName">C++ Destructor {{*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}}</DisplayString>
+ <DisplayString Condition="(Ptr & PtrMask) == StoredCXXConversionFunctionName">C++ Conversion function {{*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}}</DisplayString>
+ <DisplayString Condition="(Ptr & PtrMask) == StoredCXXOperatorName">C++ Operator {{*(clang::detail::CXXOperatorIdName *)(Ptr & ~PtrMask)}}</DisplayString>
<DisplayString Condition="(Ptr & PtrMask) == StoredDeclarationNameExtra"
- IncludeView="cpp">{*(clang::DeclarationNameExtra *)(Ptr & ~PtrMask),view(cpp)}</DisplayString>
- <DisplayString Condition="(Ptr & PtrMask) == StoredDeclarationNameExtra">{{Extra ({*(clang::DeclarationNameExtra *)(Ptr & ~PtrMask)})}}</DisplayString>
+ IncludeView="cpp">{*(clang::detail::DeclarationNameExtra *)(Ptr & ~PtrMask),view(cpp)}</DisplayString>
+ <DisplayString Condition="(Ptr & PtrMask) == StoredDeclarationNameExtra">{{Extra ({*(clang::detail::DeclarationNameExtra *)(Ptr & ~PtrMask)})}}</DisplayString>
<Expand>
<Item Condition="(Ptr & PtrMask) == StoredIdentifier" Name="[Identifier]">*(clang::IdentifierInfo *)(Ptr & ~PtrMask)</Item>
<Item Condition="(Ptr & PtrMask) == StoredObjCZeroArgSelector" Name="[ObjC Zero Arg Selector]">*(clang::IdentifierInfo *)(Ptr & ~PtrMask)</Item>
<Item Condition="(Ptr & PtrMask) == StoredObjCOneArgSelector" Name="[ObjC One Arg Selector]">*(clang::IdentifierInfo *)(Ptr & ~PtrMask)</Item>
- <Item Condition="(Ptr & PtrMask) == StoredDeclarationNameExtra" Name="[Extra]">(clang::DeclarationNameExtra *)(Ptr & ~PtrMask)</Item>
+ <Item Condition="(Ptr & PtrMask) == StoredCXXConstructorName" Name="[C++ Constructor]">*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)</Item>
+ <Item Condition="(Ptr & PtrMask) == StoredCXXDestructorName" Name="[C++ Destructor]">*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)</Item>
+ <Item Condition="(Ptr & PtrMask) == StoredCXXConversionFunctionName" Name="[C++ Conversion function]">*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)</Item>
+ <Item Condition="(Ptr & PtrMask) == StoredCXXOperatorName" Name="[C++ Operator]">*(clang::detail::CXXOperatorIdName *)(Ptr & ~PtrMask)</Item>
+ <Item Condition="(Ptr & PtrMask) == StoredDeclarationNameExtra" Name="[Extra]">(clang::detail::DeclarationNameExtra *)(Ptr & ~PtrMask)</Item>
</Expand>
</Type>
- <Type Name="clang::DeclarationNameExtra">
- <DisplayString IncludeView="cpp"
- Condition="ExtraKindOrNumArgs >= clang::DeclarationNameExtra::CXXConstructor
- && ExtraKindOrNumArgs <= clang::DeclarationNameExtra::CXXConversionFunction"
- >{((clang::CXXSpecialName *)this)->Type,view(cpp)}</DisplayString>
- <DisplayString>{(clang::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{" ",sb}{*this,view(cpp)}</DisplayString>
+ <Type Name="clang::detail::DeclarationNameExtra">
+ <DisplayString Condition="ExtraKindOrNumArgs == CXXDeductionGuideName">C++ Deduction guide</DisplayString>
+ <DisplayString Condition="ExtraKindOrNumArgs == CXXLiteralOperatorName">C++ Literal operator</DisplayString>
+ <DisplayString Condition="ExtraKindOrNumArgs == CXXUsingDirective">C++ Using directive</DisplayString>
+ <DisplayString>{(clang::detail::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{" ",sb}{*this,view(cpp)}</DisplayString>
</Type>
<Type Name="clang::Token">
<DisplayString Condition="Kind != clang::tok::identifier">{(clang::tok::TokenKind)Kind,en}</DisplayString>
@@ -458,17 +520,17 @@ For later versions of Visual Studio, no setup is required--> </Type>
<Type Name="clang::FunctionDecl">
<DisplayString IncludeView="retType">{*(clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType,view(retType)}</DisplayString>
- <DisplayString IncludeView="parm0" Condition="0 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams"></DisplayString>
+ <DisplayString IncludeView="parm0" Condition="0 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams"></DisplayString>
<DisplayString IncludeView="parm0">{*ParamInfo[0]}{*this,view(parm1)nd}</DisplayString>
- <DisplayString IncludeView="parm1" Condition="1 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams"></DisplayString>
+ <DisplayString IncludeView="parm1" Condition="1 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams"></DisplayString>
<DisplayString IncludeView="parm1">, {*ParamInfo[1]}{*this,view(parm2)nd}</DisplayString>
- <DisplayString IncludeView="parm2" Condition="2 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams"></DisplayString>
+ <DisplayString IncludeView="parm2" Condition="2 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams"></DisplayString>
<DisplayString IncludeView="parm2">, {*ParamInfo[2]}{*this,view(parm3)nd}</DisplayString>
- <DisplayString IncludeView="parm3" Condition="3 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams"></DisplayString>
+ <DisplayString IncludeView="parm3" Condition="3 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams"></DisplayString>
<DisplayString IncludeView="parm3">, {*ParamInfo[3]}{*this,view(parm4)nd}</DisplayString>
- <DisplayString IncludeView="parm4" Condition="4 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams"></DisplayString>
+ <DisplayString IncludeView="parm4" Condition="4 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams"></DisplayString>
<DisplayString IncludeView="parm4">, {*ParamInfo[4]}{*this,view(parm5)nd}</DisplayString>
- <DisplayString IncludeView="parm5" Condition="5 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams"></DisplayString>
+ <DisplayString IncludeView="parm5" Condition="5 == ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams"></DisplayString>
<DisplayString IncludeView="parm5">, /* expand for more params */</DisplayString>
<DisplayString>{*this,view(retType)nd} {Name,view(cpp)nd}({*this,view(parm0)nd})</DisplayString>
<Expand>
@@ -477,24 +539,11 @@ For later versions of Visual Studio, no setup is required--> <DisplayString>{*this,view(parm0)nd}</DisplayString>
<Expand>
<ArrayItems>
- <Size>((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams</Size>
+ <Size>((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->FunctionTypeBits.NumParams</Size>
<ValuePointer>ParamInfo</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
- <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
- </Expand>
- </Type>
- <Type Name="clang::OpaquePtr<clang::QualType>">
- <DisplayString>{*(clang::QualType *)this}</DisplayString>
- <Expand>
- <Item Name="Ptr">*(clang::QualType *)this</Item>
- </Expand>
- </Type>
- <Type Name="clang::UnionOpaquePtr<clang::QualType>">
- <DisplayString>{*(clang::QualType *)this}</DisplayString>
- <Expand>
- <Item Name="Ptr">*(clang::QualType *)this</Item>
</Expand>
</Type>
<Type Name="clang::OpaquePtr<*>">
@@ -546,6 +595,10 @@ For later versions of Visual Studio, no setup is required--> <DisplayString IncludeView="access" Condition="(Ptr&Mask) == clang::AS_none">b</DisplayString>
<DisplayString IncludeView="decl">{*(clang::NamedDecl *)(Ptr&~Mask)}</DisplayString>
<DisplayString>{*this,view(access)} {*this,view(decl)}</DisplayString>
+ <Expand>
+ <Item Name="access">(clang::AccessSpecifier)(Ptr&Mask),en</Item>
+ <Item Name="decl">*(clang::NamedDecl *)(Ptr&~Mask)</Item>
+ </Expand>
</Type>
<Type Name="clang::UnresolvedSet<*>">
<DisplayString>{Decls}</DisplayString>
@@ -557,30 +610,18 @@ For later versions of Visual Studio, no setup is required--> <DisplayString Condition="ResultKind == clang::LookupResult::Ambiguous">{Ambiguity,en}: {Decls}</DisplayString>
<DisplayString>{ResultKind,en}: {Decls}</DisplayString>
</Type>
- <Type Name="clang::ActionResult<*>" IncludeView="packedValidity">
- <DisplayString Condition="PtrWithInvalid&1">Invalid</DisplayString>
- <DisplayString Condition="!(PtrWithInvalid&1)">Valid</DisplayString>
- </Type>
- <Type Name="clang::ActionResult<*>" IncludeView="unpackedValidity">
+ <Type Name="clang::ActionResult<*, 0>">
<DisplayString Condition="Invalid">Invalid</DisplayString>
- <DisplayString Condition="!Invalid">Valid</DisplayString>
+ <DisplayString Condition="!*(void **)&Val">Unset</DisplayString>
+ <DisplayString>{Val}</DisplayString>
</Type>
- <Type Name="clang::ActionResult<*>" IncludeView="packed">
- <DisplayString>{*this,view(packedValidity)}: {($T1 *)(PtrWithInvalid&~1)}</DisplayString>
+ <Type Name="clang::ActionResult<*, 1>">
+ <DisplayString Condition="PtrWithInvalid&1">Invalid</DisplayString>
+ <DisplayString Condition="!PtrWithInvalid">Unset</DisplayString>
+ <DisplayString>{($T1)(PtrWithInvalid&~1)}</DisplayString>
<Expand>
<Item Name="Invalid">(bool)(PtrWithInvalid&1)</Item>
- <Item Name="Val">($T1 *)(PtrWithInvalid&~1)</Item>
- </Expand>
- </Type>
- <Type Name="clang::ActionResult<*>" IncludeView="unpacked">
- <DisplayString>{*this,view(unpackedValidity)}: {Val}</DisplayString>
- </Type>
- <Type Name="clang::ActionResult<*>">
- <DisplayString Condition="$T2">{*this,view(packed)}</DisplayString>
- <DisplayString Condition="!$T2">{*this,view(unpacked)}</DisplayString>
- <Expand>
- <ExpandedItem Condition="$T2">*this,view(packed)</ExpandedItem>
- <ExpandedItem Condition="!$T2">*this,view(unpacked)</ExpandedItem>
+ <Item Name="Val">($T1)(PtrWithInvalid&~1)</Item>
</Expand>
</Type>
</AutoVisualizer>
diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 6b3df825808f..874ad2df0031 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -603,14 +603,15 @@ namespace { OS << " OS << \""; } - void writeDump(raw_ostream &OS) const override {} + void writeDump(raw_ostream &OS) const override { + OS << " if (!SA->is" << getUpperName() << "Expr())\n"; + OS << " dumpType(SA->get" << getUpperName() + << "Type()->getType());\n"; + } void writeDumpChildren(raw_ostream &OS) const override { OS << " if (SA->is" << getUpperName() << "Expr())\n"; OS << " dumpStmt(SA->get" << getUpperName() << "Expr());\n"; - OS << " else\n"; - OS << " dumpType(SA->get" << getUpperName() - << "Type()->getType());\n"; } void writeHasChildren(raw_ostream &OS) const override { @@ -1885,19 +1886,15 @@ void PragmaClangAttributeSupport::emitMatchRuleList(raw_ostream &OS) { bool PragmaClangAttributeSupport::isAttributedSupported( const Record &Attribute) { - if (Attribute.getValueAsBit("ForcePragmaAttributeSupport")) - return true; + // If the attribute explicitly specified whether to support #pragma clang + // attribute, use that setting. + bool Unset; + bool SpecifiedResult = + Attribute.getValueAsBitOrUnset("PragmaAttributeSupport", Unset); + if (!Unset) + return SpecifiedResult; + // Opt-out rules: - // FIXME: The documentation check should be moved before - // the ForcePragmaAttributeSupport check after annotate is documented. - // No documentation present. - if (Attribute.isValueUnset("Documentation")) - return false; - std::vector<Record *> Docs = Attribute.getValueAsListOfDefs("Documentation"); - if (Docs.empty()) - return false; - if (Docs.size() == 1 && Docs[0]->getName() == "Undocumented") - return false; // An attribute requires delayed parsing (LateParsed is on) if (Attribute.getValueAsBit("LateParsed")) return false; @@ -2470,8 +2467,10 @@ namespace { static const AttrClassDescriptor AttrClassDescriptors[] = { { "ATTR", "Attr" }, + { "TYPE_ATTR", "TypeAttr" }, { "STMT_ATTR", "StmtAttr" }, { "INHERITABLE_ATTR", "InheritableAttr" }, + { "DECL_OR_TYPE_ATTR", "DeclOrTypeAttr" }, { "INHERITABLE_PARAM_ATTR", "InheritableParamAttr" }, { "PARAMETER_ABI_ATTR", "ParameterABIAttr" } }; @@ -2937,9 +2936,9 @@ void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) { if (I != List.cbegin()) OS << " else "; if (I->first.empty()) - OS << "if (!Scope || Scope->getName() == \"\") {\n"; + OS << "if (ScopeName == \"\") {\n"; else - OS << "if (Scope->getName() == \"" << I->first << "\") {\n"; + OS << "if (ScopeName == \"" << I->first << "\") {\n"; OS << " return llvm::StringSwitch<int>(Name)\n"; GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first); OS << "}"; @@ -3335,7 +3334,7 @@ static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) { SS << (Warn ? "warn_attribute_wrong_decl_type_str" : "err_attribute_wrong_decl_type_str"); SS << ")\n"; - SS << " << Attr.getName() << "; + SS << " << Attr << "; SS << CalculateDiagnostic(*SubjectObj) << ";\n"; SS << " return false;\n"; SS << " }\n"; @@ -3699,39 +3698,67 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { } // Emits the code to dump an attribute. -void EmitClangAttrDump(RecordKeeper &Records, raw_ostream &OS) { - emitSourceFileHeader("Attribute dumper", OS); +void EmitClangAttrTextNodeDump(RecordKeeper &Records, raw_ostream &OS) { + emitSourceFileHeader("Attribute text node dumper", OS); - OS << " switch (A->getKind()) {\n"; std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"), Args; for (const auto *Attr : Attrs) { const Record &R = *Attr; if (!R.getValueAsBit("ASTNode")) continue; - OS << " case attr::" << R.getName() << ": {\n"; // If the attribute has a semantically-meaningful name (which is determined // by whether there is a Spelling enumeration for it), then write out the // spelling used for the attribute. + + std::string FunctionContent; + llvm::raw_string_ostream SS(FunctionContent); + std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(R); if (Spellings.size() > 1 && !SpellingNamesAreCommon(Spellings)) - OS << " OS << \" \" << A->getSpelling();\n"; + SS << " OS << \" \" << A->getSpelling();\n"; Args = R.getValueAsListOfDefs("Args"); - if (!Args.empty()) { - OS << " const auto *SA = cast<" << R.getName() - << "Attr>(A);\n"; - for (const auto *Arg : Args) - createArgument(*Arg, R.getName())->writeDump(OS); + for (const auto *Arg : Args) + createArgument(*Arg, R.getName())->writeDump(SS); + + if (SS.tell()) { + OS << " void Visit" << R.getName() << "Attr(const " << R.getName() + << "Attr *A) {\n"; + if (!Args.empty()) + OS << " const auto *SA = cast<" << R.getName() + << "Attr>(A); (void)SA;\n"; + OS << SS.str(); + OS << " }\n"; + } + } +} - for (const auto *AI : Args) - createArgument(*AI, R.getName())->writeDumpChildren(OS); +void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) { + emitSourceFileHeader("Attribute text node traverser", OS); + + std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr"), Args; + for (const auto *Attr : Attrs) { + const Record &R = *Attr; + if (!R.getValueAsBit("ASTNode")) + continue; + + std::string FunctionContent; + llvm::raw_string_ostream SS(FunctionContent); + + Args = R.getValueAsListOfDefs("Args"); + for (const auto *Arg : Args) + createArgument(*Arg, R.getName())->writeDumpChildren(SS); + if (SS.tell()) { + OS << " void Visit" << R.getName() << "Attr(const " << R.getName() + << "Attr *A) {\n"; + if (!Args.empty()) + OS << " const auto *SA = cast<" << R.getName() + << "Attr>(A); (void)SA;\n"; + OS << SS.str(); + OS << " }\n"; } - OS << - " break;\n" - " }\n"; } - OS << " }\n"; } void EmitClangAttrParserStringSwitches(RecordKeeper &Records, @@ -3749,18 +3776,66 @@ void EmitClangAttrSubjectMatchRulesParserStringSwitches(RecordKeeper &Records, getPragmaAttributeSupport(Records).generateParsingHelpers(OS); } +enum class SpellingKind { + GNU, + CXX11, + C2x, + Declspec, + Microsoft, + Keyword, + Pragma, +}; +static const size_t NumSpellingKinds = (size_t)SpellingKind::Pragma + 1; + +class SpellingList { + std::vector<std::string> Spellings[NumSpellingKinds]; + +public: + ArrayRef<std::string> operator[](SpellingKind K) const { + return Spellings[(size_t)K]; + } + + void add(const Record &Attr, FlattenedSpelling Spelling) { + SpellingKind Kind = StringSwitch<SpellingKind>(Spelling.variety()) + .Case("GNU", SpellingKind::GNU) + .Case("CXX11", SpellingKind::CXX11) + .Case("C2x", SpellingKind::C2x) + .Case("Declspec", SpellingKind::Declspec) + .Case("Microsoft", SpellingKind::Microsoft) + .Case("Keyword", SpellingKind::Keyword) + .Case("Pragma", SpellingKind::Pragma); + std::string Name; + if (!Spelling.nameSpace().empty()) { + switch (Kind) { + case SpellingKind::CXX11: + case SpellingKind::C2x: + Name = Spelling.nameSpace() + "::"; + break; + case SpellingKind::Pragma: + Name = Spelling.nameSpace() + " "; + break; + default: + PrintFatalError(Attr.getLoc(), "Unexpected namespace in spelling"); + } + } + Name += Spelling.name(); + + Spellings[(size_t)Kind].push_back(Name); + } +}; + class DocumentationData { public: const Record *Documentation; const Record *Attribute; std::string Heading; - unsigned SupportedSpellings; + SpellingList SupportedSpellings; DocumentationData(const Record &Documentation, const Record &Attribute, - const std::pair<std::string, unsigned> HeadingAndKinds) + std::pair<std::string, SpellingList> HeadingAndSpellings) : Documentation(&Documentation), Attribute(&Attribute), - Heading(std::move(HeadingAndKinds.first)), - SupportedSpellings(HeadingAndKinds.second) {} + Heading(std::move(HeadingAndSpellings.first)), + SupportedSpellings(std::move(HeadingAndSpellings.second)) {} }; static void WriteCategoryHeader(const Record *DocCategory, @@ -3776,28 +3851,21 @@ static void WriteCategoryHeader(const Record *DocCategory, OS << "\n\n"; } -enum SpellingKind { - GNU = 1 << 0, - CXX11 = 1 << 1, - C2x = 1 << 2, - Declspec = 1 << 3, - Microsoft = 1 << 4, - Keyword = 1 << 5, - Pragma = 1 << 6 -}; - -static std::pair<std::string, unsigned> -GetAttributeHeadingAndSpellingKinds(const Record &Documentation, - const Record &Attribute) { +static std::pair<std::string, SpellingList> +GetAttributeHeadingAndSpellings(const Record &Documentation, + const Record &Attribute) { // FIXME: there is no way to have a per-spelling category for the attribute // documentation. This may not be a limiting factor since the spellings // should generally be consistently applied across the category. std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(Attribute); + if (Spellings.empty()) + PrintFatalError(Attribute.getLoc(), + "Attribute has no supported spellings; cannot be " + "documented"); // Determine the heading to be used for this attribute. std::string Heading = Documentation.getValueAsString("Heading"); - bool CustomHeading = !Heading.empty(); if (Heading.empty()) { // If there's only one spelling, we can simply use that. if (Spellings.size() == 1) @@ -3821,51 +3889,11 @@ GetAttributeHeadingAndSpellingKinds(const Record &Documentation, PrintFatalError(Attribute.getLoc(), "This attribute requires a heading to be specified"); - // Gather a list of unique spellings; this is not the same as the semantic - // spelling for the attribute. Variations in underscores and other non- - // semantic characters are still acceptable. - std::vector<std::string> Names; + SpellingList SupportedSpellings; + for (const auto &I : Spellings) + SupportedSpellings.add(Attribute, I); - unsigned SupportedSpellings = 0; - for (const auto &I : Spellings) { - SpellingKind Kind = StringSwitch<SpellingKind>(I.variety()) - .Case("GNU", GNU) - .Case("CXX11", CXX11) - .Case("C2x", C2x) - .Case("Declspec", Declspec) - .Case("Microsoft", Microsoft) - .Case("Keyword", Keyword) - .Case("Pragma", Pragma); - - // Mask in the supported spelling. - SupportedSpellings |= Kind; - - std::string Name; - if ((Kind == CXX11 || Kind == C2x) && !I.nameSpace().empty()) - Name = I.nameSpace() + "::"; - Name += I.name(); - - // If this name is the same as the heading, do not add it. - if (Name != Heading) - Names.push_back(Name); - } - - // Print out the heading for the attribute. If there are alternate spellings, - // then display those after the heading. - if (!CustomHeading && !Names.empty()) { - Heading += " ("; - for (auto I = Names.begin(), E = Names.end(); I != E; ++I) { - if (I != Names.begin()) - Heading += ", "; - Heading += *I; - } - Heading += ")"; - } - if (!SupportedSpellings) - PrintFatalError(Attribute.getLoc(), - "Attribute has no supported spellings; cannot be " - "documented"); - return std::make_pair(std::move(Heading), SupportedSpellings); + return std::make_pair(std::move(Heading), std::move(SupportedSpellings)); } static void WriteDocumentation(RecordKeeper &Records, @@ -3874,23 +3902,30 @@ static void WriteDocumentation(RecordKeeper &Records, // List what spelling syntaxes the attribute supports. OS << ".. csv-table:: Supported Syntaxes\n"; - OS << " :header: \"GNU\", \"C++11\", \"C2x\", \"__declspec\", \"Keyword\","; - OS << " \"Pragma\", \"Pragma clang attribute\"\n\n"; + OS << " :header: \"GNU\", \"C++11\", \"C2x\", \"``__declspec``\","; + OS << " \"Keyword\", \"``#pragma``\", \"``#pragma clang attribute``\"\n\n"; OS << " \""; - if (Doc.SupportedSpellings & GNU) OS << "X"; - OS << "\",\""; - if (Doc.SupportedSpellings & CXX11) OS << "X"; - OS << "\",\""; - if (Doc.SupportedSpellings & C2x) OS << "X"; - OS << "\",\""; - if (Doc.SupportedSpellings & Declspec) OS << "X"; - OS << "\",\""; - if (Doc.SupportedSpellings & Keyword) OS << "X"; - OS << "\", \""; - if (Doc.SupportedSpellings & Pragma) OS << "X"; - OS << "\", \""; - if (getPragmaAttributeSupport(Records).isAttributedSupported(*Doc.Attribute)) - OS << "X"; + for (size_t Kind = 0; Kind != NumSpellingKinds; ++Kind) { + SpellingKind K = (SpellingKind)Kind; + // TODO: List Microsoft (IDL-style attribute) spellings once we fully + // support them. + if (K == SpellingKind::Microsoft) + continue; + + bool PrintedAny = false; + for (StringRef Spelling : Doc.SupportedSpellings[K]) { + if (PrintedAny) + OS << " |br| "; + OS << "``" << Spelling << "``"; + PrintedAny = true; + } + + OS << "\",\""; + } + + if (getPragmaAttributeSupport(Records).isAttributedSupported( + *Doc.Attribute)) + OS << "Yes"; OS << "\"\n\n"; // If the attribute is deprecated, print a message about it, and possibly @@ -3946,7 +3981,7 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) { if (!Undocumented) SplitDocs[Category].push_back(DocumentationData( - Doc, Attr, GetAttributeHeadingAndSpellingKinds(Doc, Attr))); + Doc, Attr, GetAttributeHeadingAndSpellings(Doc, Attr))); } } @@ -3955,10 +3990,10 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) { for (auto &I : SplitDocs) { WriteCategoryHeader(I.first, OS); - llvm::sort(I.second.begin(), I.second.end(), + llvm::sort(I.second, [](const DocumentationData &D1, const DocumentationData &D2) { return D1.Heading < D2.Heading; - }); + }); // Walk over each of the attributes in the category and write out their // documentation. @@ -3971,12 +4006,7 @@ void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records, raw_ostream &OS) { PragmaClangAttributeSupport Support = getPragmaAttributeSupport(Records); ParsedAttrMap Attrs = getParsedAttrList(Records); - unsigned NumAttrs = 0; - for (const auto &I : Attrs) { - if (Support.isAttributedSupported(*I.second)) - ++NumAttrs; - } - OS << "#pragma clang attribute supports " << NumAttrs << " attributes:\n"; + OS << "#pragma clang attribute supports the following attributes:\n"; for (const auto &I : Attrs) { if (!Support.isAttributedSupported(*I.second)) continue; @@ -4008,6 +4038,7 @@ void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records, } OS << ")\n"; } + OS << "End of supported attributes.\n"; } } // end namespace clang diff --git a/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp b/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp index bea97ae13289..7c114dbe8e18 100644 --- a/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp +++ b/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This tablegen backend emits an fficient function to translate HTML named +// This tablegen backend emits an efficient function to translate HTML named // character references to UTF-8 sequences. // //===----------------------------------------------------------------------===// diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp b/utils/TableGen/ClangDiagnosticsEmitter.cpp index 6bfb3f9f61f5..f551d9328227 100644 --- a/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -208,9 +208,9 @@ static void groupDiagnostics(const std::vector<Record*> &Diags, E = SortedGroups.end(); I != E; ++I) { MutableArrayRef<const Record *> GroupDiags = (*I)->DiagsInGroup; - llvm::sort(GroupDiags.begin(), GroupDiags.end(), beforeThanCompare); + llvm::sort(GroupDiags, beforeThanCompare); } - llvm::sort(SortedGroups.begin(), SortedGroups.end(), beforeThanCompareGroups); + llvm::sort(SortedGroups, beforeThanCompareGroups); // Warn about the same group being used anonymously in multiple places. for (SmallVectorImpl<GroupInfo *>::const_iterator I = SortedGroups.begin(), @@ -1595,10 +1595,10 @@ void EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS) { Index.push_back(RecordIndexElement(R)); } - llvm::sort(Index.begin(), Index.end(), + llvm::sort(Index, [](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) { return Lhs.Name < Rhs.Name; - }); + }); for (unsigned i = 0, e = Index.size(); i != e; ++i) { const RecordIndexElement &R = Index[i]; @@ -1694,7 +1694,7 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) { std::vector<Record*> DiagGroups = Records.getAllDerivedDefinitions("DiagGroup"); - llvm::sort(DiagGroups.begin(), DiagGroups.end(), diagGroupBeforeByName); + llvm::sort(DiagGroups, diagGroupBeforeByName); DiagGroupParentMap DGParentMap(Records); @@ -1713,10 +1713,8 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) { DiagsInPedanticSet.end()); RecordVec GroupsInPedantic(GroupsInPedanticSet.begin(), GroupsInPedanticSet.end()); - llvm::sort(DiagsInPedantic.begin(), DiagsInPedantic.end(), - beforeThanCompare); - llvm::sort(GroupsInPedantic.begin(), GroupsInPedantic.end(), - beforeThanCompare); + llvm::sort(DiagsInPedantic, beforeThanCompare); + llvm::sort(GroupsInPedantic, beforeThanCompare); PedDiags.DiagsInGroup.insert(PedDiags.DiagsInGroup.end(), DiagsInPedantic.begin(), DiagsInPedantic.end()); @@ -1765,7 +1763,7 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) { OS << "Also controls "; bool First = true; - llvm::sort(GroupInfo.SubGroups.begin(), GroupInfo.SubGroups.end()); + llvm::sort(GroupInfo.SubGroups); for (const auto &Name : GroupInfo.SubGroups) { if (!First) OS << ", "; OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_"; diff --git a/utils/TableGen/ClangOptionDocEmitter.cpp b/utils/TableGen/ClangOptionDocEmitter.cpp index 7fe487e54698..cf642ec92bd8 100644 --- a/utils/TableGen/ClangOptionDocEmitter.cpp +++ b/utils/TableGen/ClangOptionDocEmitter.cpp @@ -111,7 +111,7 @@ Documentation extractDocumentation(RecordKeeper &Records) { auto DocumentationForOption = [&](Record *R) -> DocumentedOption { auto &A = Aliases[R]; - llvm::sort(A.begin(), A.end(), CompareByName); + llvm::sort(A, CompareByName); return {R, std::move(A)}; }; @@ -120,7 +120,7 @@ Documentation extractDocumentation(RecordKeeper &Records) { Documentation D; auto &Groups = GroupsInGroup[R]; - llvm::sort(Groups.begin(), Groups.end(), CompareByLocation); + llvm::sort(Groups, CompareByLocation); for (Record *G : Groups) { D.Groups.emplace_back(); D.Groups.back().Group = G; @@ -129,7 +129,7 @@ Documentation extractDocumentation(RecordKeeper &Records) { } auto &Options = OptionsInGroup[R]; - llvm::sort(Options.begin(), Options.end(), CompareByName); + llvm::sort(Options, CompareByName); for (Record *O : Options) D.Options.push_back(DocumentationForOption(O)); diff --git a/utils/TableGen/ClangSACheckersEmitter.cpp b/utils/TableGen/ClangSACheckersEmitter.cpp index 4fda8e47e4a8..57850a438720 100644 --- a/utils/TableGen/ClangSACheckersEmitter.cpp +++ b/utils/TableGen/ClangSACheckersEmitter.cpp @@ -11,34 +11,19 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/StringMap.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" #include <map> #include <string> + using namespace llvm; //===----------------------------------------------------------------------===// // Static Analyzer Checkers Tables generation //===----------------------------------------------------------------------===// -/// True if it is specified hidden or a parent package is specified -/// as hidden, otherwise false. -static bool isHidden(const Record &R) { - if (R.getValueAsBit("Hidden")) - return true; - // Not declared as hidden, check the parent package if it is hidden. - if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("ParentPackage"))) - return isHidden(*DI->getDef()); - - return false; -} - -static bool isCheckerNamed(const Record *R) { - return !R->getValueAsString("CheckerName").empty(); -} - static std::string getPackageFullName(const Record *R); static std::string getParentPackageFullName(const Record *R) { @@ -50,17 +35,19 @@ static std::string getParentPackageFullName(const Record *R) { static std::string getPackageFullName(const Record *R) { std::string name = getParentPackageFullName(R); - if (!name.empty()) name += "."; + if (!name.empty()) + name += "."; + assert(!R->getValueAsString("PackageName").empty()); name += R->getValueAsString("PackageName"); return name; } static std::string getCheckerFullName(const Record *R) { std::string name = getParentPackageFullName(R); - if (isCheckerNamed(R)) { - if (!name.empty()) name += "."; - name += R->getValueAsString("CheckerName"); - } + if (!name.empty()) + name += "."; + assert(!R->getValueAsString("CheckerName").empty()); + name += R->getValueAsString("CheckerName"); return name; } @@ -70,129 +57,49 @@ static std::string getStringValue(const Record &R, StringRef field) { return std::string(); } -namespace { -struct GroupInfo { - llvm::DenseSet<const Record*> Checkers; - llvm::DenseSet<const Record *> SubGroups; - bool Hidden; - unsigned Index; +// Calculates the integer value representing the BitsInit object +static inline uint64_t getValueFromBitsInit(const BitsInit *B, const Record &R) { + assert(B->getNumBits() <= sizeof(uint64_t) * 8 && "BitInits' too long!"); - GroupInfo() : Hidden(false) { } -}; + uint64_t Value = 0; + for (unsigned i = 0, e = B->getNumBits(); i != e; ++i) { + const auto *Bit = dyn_cast<BitInit>(B->getBit(i)); + if (Bit) + Value |= uint64_t(Bit->getValue()) << i; + else + PrintFatalError(R.getLoc(), + "missing Documentation for " + getCheckerFullName(&R)); + } + return Value; } -static void addPackageToCheckerGroup(const Record *package, const Record *group, - llvm::DenseMap<const Record *, GroupInfo *> &recordGroupMap) { - llvm::DenseSet<const Record *> &checkers = recordGroupMap[package]->Checkers; - for (llvm::DenseSet<const Record *>::iterator - I = checkers.begin(), E = checkers.end(); I != E; ++I) - recordGroupMap[group]->Checkers.insert(*I); +static std::string getCheckerDocs(const Record &R) { + StringRef LandingPage; + if (BitsInit *BI = R.getValueAsBitsInit("Documentation")) { + uint64_t V = getValueFromBitsInit(BI, R); + if (V == 1) + LandingPage = "available_checks.html"; + else if (V == 2) + LandingPage = "alpha_checks.html"; + } + + if (LandingPage.empty()) + return ""; - llvm::DenseSet<const Record *> &subGroups = recordGroupMap[package]->SubGroups; - for (llvm::DenseSet<const Record *>::iterator - I = subGroups.begin(), E = subGroups.end(); I != E; ++I) - addPackageToCheckerGroup(*I, group, recordGroupMap); + return (llvm::Twine("https://clang-analyzer.llvm.org/") + LandingPage + "#" + + getCheckerFullName(&R)) + .str(); } namespace clang { void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) { std::vector<Record*> checkers = Records.getAllDerivedDefinitions("Checker"); - llvm::DenseMap<const Record *, unsigned> checkerRecIndexMap; - for (unsigned i = 0, e = checkers.size(); i != e; ++i) - checkerRecIndexMap[checkers[i]] = i; - - // Invert the mapping of checkers to package/group into a one to many - // mapping of packages/groups to checkers. - std::map<std::string, GroupInfo> groupInfoByName; - llvm::DenseMap<const Record *, GroupInfo *> recordGroupMap; - std::vector<Record*> packages = Records.getAllDerivedDefinitions("Package"); - for (unsigned i = 0, e = packages.size(); i != e; ++i) { - Record *R = packages[i]; - std::string fullName = getPackageFullName(R); - if (!fullName.empty()) { - GroupInfo &info = groupInfoByName[fullName]; - info.Hidden = isHidden(*R); - recordGroupMap[R] = &info; - } - } - - std::vector<Record*> - checkerGroups = Records.getAllDerivedDefinitions("CheckerGroup"); - for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i) { - Record *R = checkerGroups[i]; - std::string name = R->getValueAsString("GroupName"); - if (!name.empty()) { - GroupInfo &info = groupInfoByName[name]; - recordGroupMap[R] = &info; - } - } - for (unsigned i = 0, e = checkers.size(); i != e; ++i) { - Record *R = checkers[i]; - Record *package = nullptr; - if (DefInit * - DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage"))) - package = DI->getDef(); - if (!isCheckerNamed(R) && !package) - PrintFatalError(R->getLoc(), "Checker '" + R->getName() + - "' is neither named, nor in a package!"); - - if (isCheckerNamed(R)) { - // Create a pseudo-group to hold this checker. - std::string fullName = getCheckerFullName(R); - GroupInfo &info = groupInfoByName[fullName]; - info.Hidden = R->getValueAsBit("Hidden"); - recordGroupMap[R] = &info; - info.Checkers.insert(R); - } else { - recordGroupMap[package]->Checkers.insert(R); - } + using SortedRecords = llvm::StringMap<const Record *>; - Record *currR = isCheckerNamed(R) ? R : package; - // Insert the checker and its parent packages into the subgroups set of - // the corresponding parent package. - while (DefInit *DI - = dyn_cast<DefInit>(currR->getValueInit("ParentPackage"))) { - Record *parentPackage = DI->getDef(); - recordGroupMap[parentPackage]->SubGroups.insert(currR); - currR = parentPackage; - } - // Insert the checker into the set of its group. - if (DefInit *DI = dyn_cast<DefInit>(R->getValueInit("Group"))) - recordGroupMap[DI->getDef()]->Checkers.insert(R); - } - - // If a package is in group, add all its checkers and its sub-packages - // checkers into the group. - for (unsigned i = 0, e = packages.size(); i != e; ++i) - if (DefInit *DI = dyn_cast<DefInit>(packages[i]->getValueInit("Group"))) - addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap); - - typedef std::map<std::string, const Record *> SortedRecords; - typedef llvm::DenseMap<const Record *, unsigned> RecToSortIndex; - - SortedRecords sortedGroups; - RecToSortIndex groupToSortIndex; - OS << "\n#ifdef GET_GROUPS\n"; - { - for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i) - sortedGroups[checkerGroups[i]->getValueAsString("GroupName")] - = checkerGroups[i]; - - unsigned sortIndex = 0; - for (SortedRecords::iterator - I = sortedGroups.begin(), E = sortedGroups.end(); I != E; ++I) { - const Record *R = I->second; - - OS << "GROUP(" << "\""; - OS.write_escaped(R->getValueAsString("GroupName")) << "\""; - OS << ")\n"; - - groupToSortIndex[R] = sortIndex++; - } - } - OS << "#endif // GET_GROUPS\n\n"; + OS << "// This file is automatically generated. Do not edit this file by " + "hand.\n"; OS << "\n#ifdef GET_PACKAGES\n"; { @@ -205,17 +112,7 @@ void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) { const Record &R = *I->second; OS << "PACKAGE(" << "\""; - OS.write_escaped(getPackageFullName(&R)) << "\", "; - // Group index - if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) - OS << groupToSortIndex[DI->getDef()] << ", "; - else - OS << "-1, "; - // Hidden bit - if (isHidden(R)) - OS << "true"; - else - OS << "false"; + OS.write_escaped(getPackageFullName(&R)) << '\"'; OS << ")\n"; } } @@ -226,98 +123,15 @@ void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) { const Record &R = *checkers[i]; OS << "CHECKER(" << "\""; - std::string name; - if (isCheckerNamed(&R)) - name = getCheckerFullName(&R); - OS.write_escaped(name) << "\", "; + OS.write_escaped(getCheckerFullName(&R)) << "\", "; OS << R.getName() << ", "; - OS << getStringValue(R, "DescFile") << ", "; OS << "\""; OS.write_escaped(getStringValue(R, "HelpText")) << "\", "; - // Group index - if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) - OS << groupToSortIndex[DI->getDef()] << ", "; - else - OS << "-1, "; - // Hidden bit - if (isHidden(R)) - OS << "true"; - else - OS << "false"; + OS << "\""; + OS.write_escaped(getCheckerDocs(R)); + OS << "\""; OS << ")\n"; } OS << "#endif // GET_CHECKERS\n\n"; - - unsigned index = 0; - for (std::map<std::string, GroupInfo>::iterator - I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I) - I->second.Index = index++; - - // Walk through the packages/groups/checkers emitting an array for each - // set of checkers and an array for each set of subpackages. - - OS << "\n#ifdef GET_MEMBER_ARRAYS\n"; - unsigned maxLen = 0; - for (std::map<std::string, GroupInfo>::iterator - I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I) { - maxLen = std::max(maxLen, (unsigned)I->first.size()); - - llvm::DenseSet<const Record *> &checkers = I->second.Checkers; - if (!checkers.empty()) { - OS << "static const short CheckerArray" << I->second.Index << "[] = { "; - // Make the output order deterministic. - std::map<int, const Record *> sorted; - for (llvm::DenseSet<const Record *>::iterator - I = checkers.begin(), E = checkers.end(); I != E; ++I) - sorted[(*I)->getID()] = *I; - - for (std::map<int, const Record *>::iterator - I = sorted.begin(), E = sorted.end(); I != E; ++I) - OS << checkerRecIndexMap[I->second] << ", "; - OS << "-1 };\n"; - } - - llvm::DenseSet<const Record *> &subGroups = I->second.SubGroups; - if (!subGroups.empty()) { - OS << "static const short SubPackageArray" << I->second.Index << "[] = { "; - // Make the output order deterministic. - std::map<int, const Record *> sorted; - for (llvm::DenseSet<const Record *>::iterator - I = subGroups.begin(), E = subGroups.end(); I != E; ++I) - sorted[(*I)->getID()] = *I; - - for (std::map<int, const Record *>::iterator - I = sorted.begin(), E = sorted.end(); I != E; ++I) { - OS << recordGroupMap[I->second]->Index << ", "; - } - OS << "-1 };\n"; - } - } - OS << "#endif // GET_MEMBER_ARRAYS\n\n"; - - OS << "\n#ifdef GET_CHECKNAME_TABLE\n"; - for (std::map<std::string, GroupInfo>::iterator - I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I) { - // Group option string. - OS << " { \""; - OS.write_escaped(I->first) << "\"," - << std::string(maxLen-I->first.size()+1, ' '); - - if (I->second.Checkers.empty()) - OS << "0, "; - else - OS << "CheckerArray" << I->second.Index << ", "; - - // Subgroups. - if (I->second.SubGroups.empty()) - OS << "0, "; - else - OS << "SubPackageArray" << I->second.Index << ", "; - - OS << (I->second.Hidden ? "true" : "false"); - - OS << " },\n"; - } - OS << "#endif // GET_CHECKNAME_TABLE\n\n"; } } // end namespace clang diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp index eca03a5892e2..f92110d5d7ac 100644 --- a/utils/TableGen/NeonEmitter.cpp +++ b/utils/TableGen/NeonEmitter.cpp @@ -494,6 +494,7 @@ private: std::pair<Type, std::string> emitDagSaveTemp(DagInit *DI); std::pair<Type, std::string> emitDagSplat(DagInit *DI); std::pair<Type, std::string> emitDagDup(DagInit *DI); + std::pair<Type, std::string> emitDagDupTyped(DagInit *DI); std::pair<Type, std::string> emitDagShuffle(DagInit *DI); std::pair<Type, std::string> emitDagCast(DagInit *DI, bool IsBitCast); std::pair<Type, std::string> emitDagCall(DagInit *DI); @@ -897,6 +898,18 @@ void Type::applyModifier(char Mod) { Float = true; ElementBitwidth = 16; break; + case '0': + Float = true; + if (AppliedQuad) + Bitwidth /= 2; + ElementBitwidth = 16; + break; + case '1': + Float = true; + if (!AppliedQuad) + Bitwidth *= 2; + ElementBitwidth = 16; + break; case 'g': if (AppliedQuad) Bitwidth /= 2; @@ -1507,6 +1520,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag(DagInit *DI) { return emitDagShuffle(DI); if (Op == "dup") return emitDagDup(DI); + if (Op == "dup_typed") + return emitDagDupTyped(DI); if (Op == "splat") return emitDagSplat(DI); if (Op == "save_temp") @@ -1771,6 +1786,28 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup(DagInit *DI) { return std::make_pair(T, S); } +std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped(DagInit *DI) { + assert_with_loc(DI->getNumArgs() == 2, "dup_typed() expects two arguments"); + std::pair<Type, std::string> A = emitDagArg(DI->getArg(0), + DI->getArgNameStr(0)); + std::pair<Type, std::string> B = emitDagArg(DI->getArg(1), + DI->getArgNameStr(1)); + assert_with_loc(B.first.isScalar(), + "dup_typed() requires a scalar as the second argument"); + + Type T = A.first; + assert_with_loc(T.isVector(), "dup_typed() used but target type is scalar!"); + std::string S = "(" + T.str() + ") {"; + for (unsigned I = 0; I < T.getNumElements(); ++I) { + if (I != 0) + S += ", "; + S += B.second; + } + S += "}"; + + return std::make_pair(T, S); +} + std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat(DagInit *DI) { assert_with_loc(DI->getNumArgs() == 2, "splat() expects two arguments"); std::pair<Type, std::string> A = emitDagArg(DI->getArg(0), @@ -2020,7 +2057,7 @@ void NeonEmitter::createIntrinsic(Record *R, } } - llvm::sort(NewTypeSpecs.begin(), NewTypeSpecs.end()); + llvm::sort(NewTypeSpecs); NewTypeSpecs.erase(std::unique(NewTypeSpecs.begin(), NewTypeSpecs.end()), NewTypeSpecs.end()); auto &Entry = IntrinsicMap[Name]; @@ -2409,7 +2446,7 @@ void NeonEmitter::run(raw_ostream &OS) { OS << "#endif\n"; OS << "\n"; - OS << "#define __ai static inline __attribute__((__always_inline__, " + OS << "#define __ai static __inline__ __attribute__((__always_inline__, " "__nodebug__))\n\n"; SmallVector<Intrinsic *, 128> Defs; @@ -2518,7 +2555,7 @@ void NeonEmitter::runFP16(raw_ostream &OS) { OS << "typedef __fp16 float16_t;\n"; - OS << "#define __ai static inline __attribute__((__always_inline__, " + OS << "#define __ai static __inline__ __attribute__((__always_inline__, " "__nodebug__))\n\n"; SmallVector<Intrinsic *, 128> Defs; diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index a2ba131628f1..f40d7f123353 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -23,6 +23,8 @@ using namespace llvm; using namespace clang; enum ActionType { + PrintRecords, + DumpJSON, GenClangAttrClasses, GenClangAttrParserStringSwitches, GenClangAttrSubjectMatchRulesParserStringSwitches, @@ -38,7 +40,8 @@ enum ActionType { GenClangAttrParsedAttrList, GenClangAttrParsedAttrImpl, GenClangAttrParsedAttrKinds, - GenClangAttrDump, + GenClangAttrTextNodeDump, + GenClangAttrNodeTraverse, GenClangDiagsDefs, GenClangDiagGroups, GenClangDiagsIndexName, @@ -66,6 +69,10 @@ namespace { cl::opt<ActionType> Action( cl::desc("Action to perform:"), cl::values( + clEnumValN(PrintRecords, "print-records", + "Print all records to stdout (default)"), + clEnumValN(DumpJSON, "dump-json", + "Dump all records as machine-readable JSON"), clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes", "Generate clang attribute clases"), clEnumValN(GenClangAttrParserStringSwitches, @@ -106,8 +113,10 @@ cl::opt<ActionType> Action( clEnumValN(GenClangAttrParsedAttrKinds, "gen-clang-attr-parsed-attr-kinds", "Generate a clang parsed attribute kinds"), - clEnumValN(GenClangAttrDump, "gen-clang-attr-dump", - "Generate clang attribute dumper"), + clEnumValN(GenClangAttrTextNodeDump, "gen-clang-attr-text-node-dump", + "Generate clang attribute text node dumper"), + clEnumValN(GenClangAttrNodeTraverse, "gen-clang-attr-node-traverse", + "Generate clang attribute traverser"), clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs", "Generate Clang diagnostics definitions"), clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups", @@ -164,6 +173,12 @@ ClangComponent("clang-component", bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) { switch (Action) { + case PrintRecords: + OS << Records; // No argument, dump all contents + break; + case DumpJSON: + EmitJSON(Records, OS); + break; case GenClangAttrClasses: EmitClangAttrClass(Records, OS); break; @@ -209,8 +224,11 @@ bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) { case GenClangAttrParsedAttrKinds: EmitClangAttrParsedAttrKinds(Records, OS); break; - case GenClangAttrDump: - EmitClangAttrDump(Records, OS); + case GenClangAttrTextNodeDump: + EmitClangAttrTextNodeDump(Records, OS); + break; + case GenClangAttrNodeTraverse: + EmitClangAttrNodeTraverse(Records, OS); break; case GenClangDiagsDefs: EmitClangDiagsDefs(Records, OS, ClangComponent); diff --git a/utils/TableGen/TableGenBackends.h b/utils/TableGen/TableGenBackends.h index 706e812ae874..410d0100be19 100644 --- a/utils/TableGen/TableGenBackends.h +++ b/utils/TableGen/TableGenBackends.h @@ -23,63 +23,63 @@ namespace llvm { class RecordKeeper; } -using llvm::raw_ostream; -using llvm::RecordKeeper; - namespace clang { -void EmitClangDeclContext(RecordKeeper &RK, raw_ostream &OS); -void EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS, +void EmitClangDeclContext(llvm::RecordKeeper &RK, llvm::raw_ostream &OS); +void EmitClangASTNodes(llvm::RecordKeeper &RK, llvm::raw_ostream &OS, const std::string &N, const std::string &S); -void EmitClangAttrParserStringSwitches(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSubjectMatchRulesParserStringSwitches(RecordKeeper &Records, - raw_ostream &OS); -void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrDump(RecordKeeper &Records, raw_ostream &OS); - -void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, +void EmitClangAttrParserStringSwitches(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrSubjectMatchRulesParserStringSwitches(llvm::RecordKeeper &Records, + llvm::raw_ostream &OS); +void EmitClangAttrClass(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrSubjectMatchRuleList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrPCHRead(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrPCHWrite(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrHasAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrSpellingListIndex(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrASTVisitor(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrTemplateInstantiate(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrParsedAttrList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrParsedAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrParsedAttrKinds(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrTextNodeDump(llvm::RecordKeeper &Records, + llvm::raw_ostream &OS); +void EmitClangAttrNodeTraverse(llvm::RecordKeeper &Records, + llvm::raw_ostream &OS); + +void EmitClangDiagsDefs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS, const std::string &Component); -void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS); -void EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS); +void EmitClangDiagGroups(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangDiagsIndexName(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS); +void EmitClangSACheckers(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS); -void EmitClangCommentHTMLTagsProperties(RecordKeeper &Records, raw_ostream &OS); -void EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records, raw_ostream &OS); +void EmitClangCommentHTMLTags(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangCommentCommandInfo(RecordKeeper &Records, raw_ostream &OS); -void EmitClangCommentCommandList(RecordKeeper &Records, raw_ostream &OS); +void EmitClangCommentCommandInfo(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangCommentCommandList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitNeon(RecordKeeper &Records, raw_ostream &OS); -void EmitFP16(RecordKeeper &Records, raw_ostream &OS); -void EmitNeonSema(RecordKeeper &Records, raw_ostream &OS); -void EmitNeonTest(RecordKeeper &Records, raw_ostream &OS); -void EmitNeon2(RecordKeeper &Records, raw_ostream &OS); -void EmitNeonSema2(RecordKeeper &Records, raw_ostream &OS); -void EmitNeonTest2(RecordKeeper &Records, raw_ostream &OS); +void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitNeonSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitNeonTest(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitNeon2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitNeonSema2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitNeonTest2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS); -void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS); -void EmitClangOptDocs(RecordKeeper &Records, raw_ostream &OS); +void EmitClangAttrDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangDiagDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangOptDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangDataCollectors(RecordKeeper &Records, raw_ostream &OS); +void EmitClangDataCollectors(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records, - raw_ostream &OS); +void EmitTestPragmaAttributeSupportedAttributes(llvm::RecordKeeper &Records, + llvm::raw_ostream &OS); } // end namespace clang diff --git a/utils/TestUtils/deep-stack.py b/utils/TestUtils/deep-stack.py index 1750a5fca031..10bf47acb1f7 100755 --- a/utils/TestUtils/deep-stack.py +++ b/utils/TestUtils/deep-stack.py @@ -1,22 +1,23 @@ #!/usr/bin/env python +from __future__ import absolute_import, division, print_function def pcall(f, N): if N == 0: - print >>f, ' f(0)' + print(' f(0)', file=f) return - print >>f, ' f(' + print(' f(', file=f) pcall(f, N - 1) - print >>f, ' )' + print(' )', file=f) def main(): f = open('t.c','w') - print >>f, 'int f(int n) { return n; }' - print >>f, 'int t() {' - print >>f, ' return' + print('int f(int n) { return n; }', file=f) + print('int t() {', file=f) + print(' return', file=f) pcall(f, 10000) - print >>f, ' ;' - print >>f, '}' + print(' ;', file=f) + print('}', file=f) if __name__ == "__main__": import sys diff --git a/utils/analyzer/CmpRuns.py b/utils/analyzer/CmpRuns.py index 7c9744727e90..be503499622d 100755 --- a/utils/analyzer/CmpRuns.py +++ b/utils/analyzer/CmpRuns.py @@ -25,6 +25,7 @@ Usage: diff = compareResults(resultsA, resultsB) """ +from __future__ import division, print_function from collections import defaultdict @@ -38,7 +39,7 @@ import sys STATS_REGEXP = re.compile(r"Statistics: (\{.+\})", re.MULTILINE | re.DOTALL) -class Colors: +class Colors(object): """ Color for terminal highlight. """ @@ -50,14 +51,14 @@ class Colors: # path - the analysis output directory # root - the name of the root directory, which will be disregarded when # determining the source file name -class SingleRunInfo: +class SingleRunInfo(object): def __init__(self, path, root="", verboseLog=None): self.path = path self.root = root.rstrip("/\\") self.verboseLog = verboseLog -class AnalysisDiagnostic: +class AnalysisDiagnostic(object): def __init__(self, data, report, htmlReport): self._data = data self._loc = self._data['location'] @@ -117,14 +118,14 @@ class AnalysisDiagnostic: return self._data -class AnalysisReport: +class AnalysisReport(object): def __init__(self, run, files): self.run = run self.files = files self.diagnostics = [] -class AnalysisRun: +class AnalysisRun(object): def __init__(self, info): self.path = info.path self.root = info.root @@ -281,19 +282,33 @@ def compareResults(A, B, opts): return res +def computePercentile(l, percentile): + """ + Return computed percentile. + """ + return sorted(l)[int(round(percentile * len(l) + 0.5)) - 1] + def deriveStats(results): # Assume all keys are the same in each statistics bucket. combined_data = defaultdict(list) + + # Collect data on paths length. + for report in results.reports: + for diagnostic in report.diagnostics: + combined_data['PathsLength'].append(diagnostic.getPathLength()) + for stat in results.stats: - for key, value in stat.iteritems(): + for key, value in stat.items(): combined_data[key].append(value) combined_stats = {} - for key, values in combined_data.iteritems(): + for key, values in combined_data.items(): combined_stats[str(key)] = { "max": max(values), "min": min(values), "mean": sum(values) / len(values), - "median": sorted(values)[len(values) / 2], + "90th %tile": computePercentile(values, 0.9), + "95th %tile": computePercentile(values, 0.95), + "median": sorted(values)[len(values) // 2], "total": sum(values) } return combined_stats @@ -304,7 +319,7 @@ def compareStats(resultsA, resultsB): statsB = deriveStats(resultsB) keys = sorted(statsA.keys()) for key in keys: - print key + print(key) for kkey in statsA[key]: valA = float(statsA[key][kkey]) valB = float(statsB[key][kkey]) @@ -317,7 +332,7 @@ def compareStats(resultsA, resultsB): report = Colors.GREEN + report + Colors.CLEAR elif ratio > 0.2: report = Colors.RED + report + Colors.CLEAR - print "\t %s %s" % (kkey, report) + print("\t %s %s" % (kkey, report)) def dumpScanBuildResultsDiff(dirA, dirB, opts, deleteEmpty=True, Stdout=sys.stdout): diff --git a/utils/analyzer/SATestAdd.py b/utils/analyzer/SATestAdd.py index 041b24409fe3..52089f4e0660 100644 --- a/utils/analyzer/SATestAdd.py +++ b/utils/analyzer/SATestAdd.py @@ -42,6 +42,7 @@ the Repository Directory. diff -ur CachedSource PatchedSource \ > changes_for_analyzer.patch """ +from __future__ import absolute_import, division, print_function import SATestBuild import os @@ -66,7 +67,7 @@ def addNewProject(ID, BuildMode): CurDir = os.path.abspath(os.curdir) Dir = SATestBuild.getProjectDir(ID) if not os.path.exists(Dir): - print "Error: Project directory is missing: %s" % Dir + print("Error: Project directory is missing: %s" % Dir) sys.exit(-1) # Build the project. @@ -78,30 +79,30 @@ def addNewProject(ID, BuildMode): if os.path.exists(ProjectMapPath): FileMode = "r+b" else: - print "Warning: Creating the Project Map file!!" + print("Warning: Creating the Project Map file!!") FileMode = "w+b" with open(ProjectMapPath, FileMode) as PMapFile: if (isExistingProject(PMapFile, ID)): - print >> sys.stdout, 'Warning: Project with ID \'', ID, \ - '\' already exists.' - print >> sys.stdout, "Reference output has been regenerated." + print('Warning: Project with ID \'', ID, \ + '\' already exists.', file=sys.stdout) + print("Reference output has been regenerated.", file=sys.stdout) else: PMapWriter = csv.writer(PMapFile) PMapWriter.writerow((ID, int(BuildMode))) - print "The project map is updated: ", ProjectMapPath + print("The project map is updated: ", ProjectMapPath) # TODO: Add an option not to build. # TODO: Set the path to the Repository directory. if __name__ == '__main__': if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'): - print >> sys.stderr, 'Add a new project for testing to the analyzer'\ + print('Add a new project for testing to the analyzer'\ '\nUsage: ', sys.argv[0],\ 'project_ID <mode>\n' \ 'mode: 0 for single file project, ' \ '1 for scan_build, ' \ - '2 for single file c++11 project' + '2 for single file c++11 project', file=sys.stderr) sys.exit(-1) BuildMode = 1 diff --git a/utils/analyzer/SATestBuild.py b/utils/analyzer/SATestBuild.py index ea95ee289e99..1c96cd883818 100644 --- a/utils/analyzer/SATestBuild.py +++ b/utils/analyzer/SATestBuild.py @@ -58,7 +58,10 @@ import shutil import sys import threading import time -import Queue +try: + import queue +except ImportError: + import Queue as queue ############################################################################### # Helper functions. @@ -119,7 +122,7 @@ if 'CC' in os.environ: else: Clang = SATestUtils.which("clang", os.environ['PATH']) if not Clang: - print "Error: cannot find 'clang' in PATH" + print("Error: cannot find 'clang' in PATH") sys.exit(1) # Number of jobs. @@ -255,7 +258,14 @@ def applyPatch(Dir, PBuildLogFile): sys.exit(1) -def runScanBuild(Dir, SBOutputDir, PBuildLogFile): +def generateAnalyzerConfig(Args): + Out = "serialize-stats=true,stable-report-filename=true" + if Args.extra_analyzer_config: + Out += "," + Args.extra_analyzer_config + return Out + + +def runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile): """ Build the project with scan-build by reading in the commands and prefixing them with the scan-build options. @@ -277,13 +287,7 @@ def runScanBuild(Dir, SBOutputDir, PBuildLogFile): SBOptions += "-plist-html -o '%s' " % SBOutputDir SBOptions += "-enable-checker " + AllCheckers + " " SBOptions += "--keep-empty " - AnalyzerConfig = [ - ("stable-report-filename", "true"), - ("serialize-stats", "true"), - ] - - SBOptions += "-analyzer-config '%s' " % ( - ",".join("%s=%s" % (key, value) for (key, value) in AnalyzerConfig)) + SBOptions += "-analyzer-config '%s' " % generateAnalyzerConfig(Args) # Always use ccc-analyze to ensure that we can locate the failures # directory. @@ -304,6 +308,7 @@ def runScanBuild(Dir, SBOutputDir, PBuildLogFile): SBPrefix = "" ExtraEnv['OUTPUT'] = SBOutputDir ExtraEnv['CC'] = Clang + ExtraEnv['ANALYZER_CONFIG'] = generateAnalyzerConfig(Args) continue # If using 'make', auto imply a -jX argument @@ -328,7 +333,7 @@ def runScanBuild(Dir, SBOutputDir, PBuildLogFile): sys.exit(1) -def runAnalyzePreprocessed(Dir, SBOutputDir, Mode): +def runAnalyzePreprocessed(Args, Dir, SBOutputDir, Mode): """ Run analysis on a set of preprocessed files. """ @@ -349,6 +354,7 @@ def runAnalyzePreprocessed(Dir, SBOutputDir, Mode): CmdPrefix += "-analyze -analyzer-output=plist -w " CmdPrefix += "-analyzer-checker=" + Checkers CmdPrefix += " -fcxx-exceptions -fblocks " + CmdPrefix += " -analyzer-config %s " % generateAnalyzerConfig(Args) if (Mode == 2): CmdPrefix += "-std=c++11 " @@ -379,7 +385,7 @@ def runAnalyzePreprocessed(Dir, SBOutputDir, Mode): check_call(Command, cwd=Dir, stderr=LogFile, stdout=LogFile, shell=True) - except CalledProcessError, e: + except CalledProcessError as e: Local.stderr.write("Error: Analyzes of %s failed. " "See %s for details." "Error code %d.\n" % ( @@ -407,7 +413,7 @@ def removeLogFile(SBOutputDir): check_call(RmCommand, shell=True) -def buildProject(Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild): +def buildProject(Args, Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild): TBegin = time.time() BuildLogPath = getBuildLogPath(SBOutputDir) @@ -431,9 +437,9 @@ def buildProject(Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild): if (ProjectBuildMode == 1): downloadAndPatch(Dir, PBuildLogFile) runCleanupScript(Dir, PBuildLogFile) - runScanBuild(Dir, SBOutputDir, PBuildLogFile) + runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile) else: - runAnalyzePreprocessed(Dir, SBOutputDir, ProjectBuildMode) + runAnalyzePreprocessed(Args, Dir, SBOutputDir, ProjectBuildMode) if IsReferenceBuild: runCleanupScript(Dir, PBuildLogFile) @@ -564,8 +570,8 @@ def runCmpResults(Dir, Strictness=0): NewList.remove(os.path.join(NewDir, LogFolderName)) if len(RefList) != len(NewList): - print "Mismatch in number of results folders: %s vs %s" % ( - RefList, NewList) + print("Mismatch in number of results folders: %s vs %s" % ( + RefList, NewList)) sys.exit(1) # There might be more then one folder underneath - one per each scan-build @@ -577,8 +583,7 @@ def runCmpResults(Dir, Strictness=0): # Iterate and find the differences. NumDiffs = 0 - PairList = zip(RefList, NewList) - for P in PairList: + for P in zip(RefList, NewList): RefDir = P[0] NewDir = P[1] @@ -628,12 +633,13 @@ def cleanupReferenceResults(SBOutputDir): class TestProjectThread(threading.Thread): - def __init__(self, TasksQueue, ResultsDiffer, FailureFlag): + def __init__(self, Args, TasksQueue, ResultsDiffer, FailureFlag): """ :param ResultsDiffer: Used to signify that results differ from the canonical ones. :param FailureFlag: Used to signify a failure during the run. """ + self.Args = Args self.TasksQueue = TasksQueue self.ResultsDiffer = ResultsDiffer self.FailureFlag = FailureFlag @@ -649,7 +655,7 @@ class TestProjectThread(threading.Thread): Logger = logging.getLogger(ProjArgs[0]) Local.stdout = StreamToLogger(Logger, logging.INFO) Local.stderr = StreamToLogger(Logger, logging.ERROR) - if not testProject(*ProjArgs): + if not testProject(Args, *ProjArgs): self.ResultsDiffer.set() self.TasksQueue.task_done() except: @@ -657,7 +663,7 @@ class TestProjectThread(threading.Thread): raise -def testProject(ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0): +def testProject(Args, ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0): """ Test a given project. :return TestsPassed: Whether tests have passed according @@ -675,7 +681,7 @@ def testProject(ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0): RelOutputDir = getSBOutputDirName(IsReferenceBuild) SBOutputDir = os.path.join(Dir, RelOutputDir) - buildProject(Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild) + buildProject(Args, Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild) checkBuild(SBOutputDir) @@ -712,24 +718,24 @@ def validateProjectFile(PMapFile): """ for I in iterateOverProjects(PMapFile): if len(I) != 2: - print "Error: Rows in the ProjectMapFile should have 2 entries." + print("Error: Rows in the ProjectMapFile should have 2 entries.") raise Exception() if I[1] not in ('0', '1', '2'): - print "Error: Second entry in the ProjectMapFile should be 0" \ - " (single file), 1 (project), or 2(single file c++11)." + print("Error: Second entry in the ProjectMapFile should be 0" \ + " (single file), 1 (project), or 2(single file c++11).") raise Exception() -def singleThreadedTestAll(ProjectsToTest): +def singleThreadedTestAll(Args, ProjectsToTest): """ Run all projects. :return: whether tests have passed. """ Success = True for ProjArgs in ProjectsToTest: - Success &= testProject(*ProjArgs) + Success &= testProject(Args, *ProjArgs) return Success -def multiThreadedTestAll(ProjectsToTest, Jobs): +def multiThreadedTestAll(Args, ProjectsToTest, Jobs): """ Run each project in a separate thread. @@ -738,7 +744,7 @@ def multiThreadedTestAll(ProjectsToTest, Jobs): :return: whether tests have passed. """ - TasksQueue = Queue.Queue() + TasksQueue = queue.Queue() for ProjArgs in ProjectsToTest: TasksQueue.put(ProjArgs) @@ -747,7 +753,7 @@ def multiThreadedTestAll(ProjectsToTest, Jobs): FailureFlag = threading.Event() for i in range(Jobs): - T = TestProjectThread(TasksQueue, ResultsDiffer, FailureFlag) + T = TestProjectThread(Args, TasksQueue, ResultsDiffer, FailureFlag) T.start() # Required to handle Ctrl-C gracefully. @@ -772,9 +778,9 @@ def testAll(Args): Args.regenerate, Args.strictness)) if Args.jobs <= 1: - return singleThreadedTestAll(ProjectsToTest) + return singleThreadedTestAll(Args, ProjectsToTest) else: - return multiThreadedTestAll(ProjectsToTest, Args.jobs) + return multiThreadedTestAll(Args, ProjectsToTest, Args.jobs) if __name__ == '__main__': @@ -791,9 +797,13 @@ if __name__ == '__main__': Parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=0, help='Number of projects to test concurrently') + Parser.add_argument('--extra-analyzer-config', dest='extra_analyzer_config', + type=str, + default="", + help="Arguments passed to to -analyzer-config") Args = Parser.parse_args() TestsPassed = testAll(Args) if not TestsPassed: - print "ERROR: Tests failed." + print("ERROR: Tests failed.") sys.exit(42) diff --git a/utils/analyzer/SATestUpdateDiffs.py b/utils/analyzer/SATestUpdateDiffs.py index 92bbd83172ef..ea3c08cc210c 100755 --- a/utils/analyzer/SATestUpdateDiffs.py +++ b/utils/analyzer/SATestUpdateDiffs.py @@ -3,6 +3,7 @@ """ Update reference results for static analyzer. """ +from __future__ import absolute_import, division, print_function import SATestBuild @@ -10,12 +11,12 @@ from subprocess import check_call import os import sys -Verbose = 1 +Verbose = 0 def runCmd(Command, **kwargs): if Verbose: - print "Executing %s" % Command + print("Executing %s" % Command) check_call(Command, shell=True, **kwargs) @@ -30,8 +31,8 @@ def updateReferenceResults(ProjName, ProjBuildMode): SATestBuild.getSBOutputDirName(IsReferenceBuild=False)) if not os.path.exists(CreatedResultsPath): - print >> sys.stderr, "New results not found, was SATestBuild.py "\ - "previously run?" + print("New results not found, was SATestBuild.py "\ + "previously run?", file=sys.stderr) sys.exit(1) BuildLogPath = SATestBuild.getBuildLogPath(RefResultsPath) @@ -62,9 +63,9 @@ def updateReferenceResults(ProjName, ProjBuildMode): def main(argv): if len(argv) == 2 and argv[1] in ('-h', '--help'): - print >> sys.stderr, "Update static analyzer reference results based "\ + print("Update static analyzer reference results based "\ "\non the previous run of SATestBuild.py.\n"\ - "\nN.B.: Assumes that SATestBuild.py was just run" + "\nN.B.: Assumes that SATestBuild.py was just run", file=sys.stderr) sys.exit(1) with SATestBuild.projectFileHandler() as f: diff --git a/utils/analyzer/SumTimerInfo.py b/utils/analyzer/SumTimerInfo.py index 50e1cb854f4e..36e519adbf71 100644 --- a/utils/analyzer/SumTimerInfo.py +++ b/utils/analyzer/SumTimerInfo.py @@ -6,13 +6,14 @@ Script to Summarize statistics in the scan-build output. Statistics are enabled by passing '-internal-stats' option to scan-build (or '-analyzer-stats' to the analyzer). """ +from __future__ import absolute_import, division, print_function import sys if __name__ == '__main__': if len(sys.argv) < 2: - print >> sys.stderr, 'Usage: ', sys.argv[0],\ - 'scan_build_output_file' + print('Usage: ', sys.argv[0],\ + 'scan_build_output_file', file=sys.stderr) sys.exit(-1) f = open(sys.argv[1], 'r') @@ -65,15 +66,15 @@ if __name__ == '__main__': s = line.split() TotalTime = TotalTime + float(s[6]) - print "TU Count %d" % (Count) - print "Time %f" % (Time) - print "Warnings %d" % (Warnings) - print "Functions Analyzed %d" % (FunctionsAnalyzed) - print "Reachable Blocks %d" % (ReachableBlocks) - print "Reached Max Steps %d" % (ReachedMaxSteps) - print "Number of Steps %d" % (NumSteps) - print "Number of Inlined calls %d (bifurcated %d)" % ( - NumInlinedCallSites, NumBifurcatedCallSites) - print "MaxTime %f" % (MaxTime) - print "TotalTime %f" % (TotalTime) - print "Max CFG Size %d" % (MaxCFGSize) + print("TU Count %d" % (Count)) + print("Time %f" % (Time)) + print("Warnings %d" % (Warnings)) + print("Functions Analyzed %d" % (FunctionsAnalyzed)) + print("Reachable Blocks %d" % (ReachableBlocks)) + print("Reached Max Steps %d" % (ReachedMaxSteps)) + print("Number of Steps %d" % (NumSteps)) + print("Number of Inlined calls %d (bifurcated %d)" % ( + NumInlinedCallSites, NumBifurcatedCallSites)) + print("MaxTime %f" % (MaxTime)) + print("TotalTime %f" % (TotalTime)) + print("Max CFG Size %d" % (MaxCFGSize)) diff --git a/utils/analyzer/ubiviz b/utils/analyzer/ubiviz deleted file mode 100755 index 137e130fe74c..000000000000 --- a/utils/analyzer/ubiviz +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===--------------------------------------------------------------------===## -# -# This script reads visualization data emitted by the static analyzer for -# display in Ubigraph. -# -##===--------------------------------------------------------------------===## - -import xmlrpclib -import sys - - -def Error(message): - print >> sys.stderr, 'ubiviz: ' + message - sys.exit(1) - - -def StreamData(filename): - file = open(filename) - for ln in file: - yield eval(ln) - file.close() - - -def Display(G, data): - action = data[0] - if action == 'vertex': - vertex = data[1] - G.new_vertex_w_id(vertex) - for attribute in data[2:]: - G.set_vertex_attribute(vertex, attribute[0], attribute[1]) - elif action == 'edge': - src = data[1] - dst = data[2] - edge = G.new_edge(src, dst) - for attribute in data[3:]: - G.set_edge_attribute(edge, attribute[0], attribute[1]) - elif action == "vertex_style": - style_id = data[1] - parent_id = data[2] - G.new_vertex_style_w_id(style_id, parent_id) - for attribute in data[3:]: - G.set_vertex_style_attribute(style_id, attribute[0], attribute[1]) - elif action == "vertex_style_attribute": - style_id = data[1] - for attribute in data[2:]: - G.set_vertex_style_attribute(style_id, attribute[0], attribute[1]) - elif action == "change_vertex_style": - vertex_id = data[1] - style_id = data[2] - G.change_vertex_style(vertex_id, style_id) - - -def main(args): - if len(args) == 0: - Error('no input files') - - server = xmlrpclib.Server('http://127.0.0.1:20738/RPC2') - G = server.ubigraph - - for arg in args: - G.clear() - for x in StreamData(arg): - Display(G, x) - - sys.exit(0) - - -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/utils/check_cfc/check_cfc.py b/utils/check_cfc/check_cfc.py index 7a739f46e308..311f502f800b 100755 --- a/utils/check_cfc/check_cfc.py +++ b/utils/check_cfc/check_cfc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python """Check CFC - Check Compile Flow Consistency @@ -47,7 +47,7 @@ To add a new check: subclass. """ -from __future__ import print_function +from __future__ import absolute_import, division, print_function import imp import os @@ -56,7 +56,10 @@ import shutil import subprocess import sys import tempfile -import ConfigParser +try: + import configparser +except ImportError: + import ConfigParser as configparser import io import obj_diff @@ -95,8 +98,8 @@ def remove_dir_from_path(path_var, directory): PATH""" pathlist = path_var.split(os.pathsep) norm_directory = os.path.normpath(os.path.normcase(directory)) - pathlist = filter(lambda x: os.path.normpath( - os.path.normcase(x)) != norm_directory, pathlist) + pathlist = [x for x in pathlist if os.path.normpath( + os.path.normcase(x)) != norm_directory] return os.pathsep.join(pathlist) def path_without_wrapper(): @@ -318,7 +321,7 @@ if __name__ == '__main__': for c in checks: default_config += "{} = false\n".format(c) - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() config.readfp(io.BytesIO(default_config)) scriptdir = get_main_dir() config_path = os.path.join(scriptdir, 'check_cfc.cfg') diff --git a/utils/check_cfc/obj_diff.py b/utils/check_cfc/obj_diff.py index cc4c2a97d5e5..a0951c5bcdee 100755 --- a/utils/check_cfc/obj_diff.py +++ b/utils/check_cfc/obj_diff.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python -from __future__ import print_function +from __future__ import absolute_import, division, print_function import argparse import difflib @@ -25,7 +25,7 @@ def disassemble(objfile): if p.returncode or err: print("Disassemble failed: {}".format(objfile)) sys.exit(1) - return filter(keep_line, out.split(os.linesep)) + return [line for line in out.split(os.linesep) if keep_line(line)] def dump_debug(objfile): """Dump all of the debug info from a file.""" @@ -34,7 +34,7 @@ def dump_debug(objfile): if p.returncode or err: print("Dump debug failed: {}".format(objfile)) sys.exit(1) - return filter(keep_line, out.split(os.linesep)) + return [line for line in out.split(os.linesep) if keep_line(line)] def first_diff(a, b, fromfile, tofile): """Returns the first few lines of a difference, if there is one. Python diff --git a/utils/check_cfc/setup.py b/utils/check_cfc/setup.py index b5fc473639ef..64f07d5dcc52 100644 --- a/utils/check_cfc/setup.py +++ b/utils/check_cfc/setup.py @@ -1,6 +1,7 @@ """For use on Windows. Run with: python.exe setup.py py2exe """ +from __future__ import absolute_import, division, print_function from distutils.core import setup try: import py2exe @@ -8,10 +9,10 @@ except ImportError: import platform import sys if platform.system() == 'Windows': - print "Could not find py2exe. Please install then run setup.py py2exe." + print("Could not find py2exe. Please install then run setup.py py2exe.") raise else: - print "setup.py only required on Windows." + print("setup.py only required on Windows.") sys.exit(1) setup( diff --git a/utils/check_cfc/test_check_cfc.py b/utils/check_cfc/test_check_cfc.py index e304ff59277d..0808252a2c60 100755 --- a/utils/check_cfc/test_check_cfc.py +++ b/utils/check_cfc/test_check_cfc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python """Test internal functions within check_cfc.py.""" diff --git a/utils/clangdiag.py b/utils/clangdiag.py index 9a80e2696d52..6baf65a8761c 100755 --- a/utils/clangdiag.py +++ b/utils/clangdiag.py @@ -9,9 +9,9 @@ # (lldb) command script import /path/to/clandiag.py #---------------------------------------------------------------------- +from __future__ import absolute_import, division, print_function import lldb import argparse -import commands import shlex import os import re @@ -189,4 +189,4 @@ def __lldb_init_module(debugger, dict): # Add any commands contained in this module to LLDB debugger.HandleCommand( 'command script add -f clangdiag.the_diag_command clangdiag') - print 'The "clangdiag" command has been installed, type "help clangdiag" or "clangdiag --help" for detailed help.' + print('The "clangdiag" command has been installed, type "help clangdiag" or "clangdiag --help" for detailed help.') diff --git a/utils/hmaptool/hmaptool b/utils/hmaptool/hmaptool index 2b1ca7436c3f..58baab2f7746 100755 --- a/utils/hmaptool/hmaptool +++ b/utils/hmaptool/hmaptool @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function +from __future__ import absolute_import, division, print_function import json import optparse diff --git a/utils/modfuzz.py b/utils/modfuzz.py index a6aa1f1a257a..61ca3272aca5 100644 --- a/utils/modfuzz.py +++ b/utils/modfuzz.py @@ -4,6 +4,7 @@ # 1) Update the 'decls' list below with your fuzzing configuration. # 2) Run with the clang binary as the command-line argument. +from __future__ import absolute_import, division, print_function import random import subprocess import sys @@ -12,7 +13,7 @@ import os clang = sys.argv[1] none_opts = 0.3 -class Decl: +class Decl(object): def __init__(self, text, depends=[], provides=[], conflicts=[]): self.text = text self.depends = depends @@ -39,7 +40,7 @@ decls = [ Decl('X %(name)s;\n', depends=['X']), ] -class FS: +class FS(object): def __init__(self): self.fs = {} self.prevfs = {} @@ -62,7 +63,7 @@ class FS: fs = FS() -class CodeModel: +class CodeModel(object): def __init__(self): self.source = '' self.modules = {} @@ -97,7 +98,7 @@ def generate(): if not model.fails(): return except KeyboardInterrupt: - print + print() return True sys.stdout.write('\nReducing:\n') @@ -106,7 +107,7 @@ def generate(): try: while True: assert m, 'got a failure with no steps; broken clang binary?' - i = random.choice(range(len(m))) + i = random.choice(list(range(len(m)))) x = m[0:i] + m[i+1:] m2 = CodeModel() for d in x: diff --git a/utils/perf-training/perf-helper.py b/utils/perf-training/perf-helper.py index 30b9caeffd58..65afbb6ed572 100644 --- a/utils/perf-training/perf-helper.py +++ b/utils/perf-training/perf-helper.py @@ -7,7 +7,7 @@ # #===------------------------------------------------------------------------===# -from __future__ import print_function +from __future__ import absolute_import, division, print_function import sys import os @@ -114,7 +114,7 @@ def get_cc1_command_for_args(cmd, env): # Find the cc1 command used by the compiler. To do this we execute the # compiler with '-###' to figure out what it wants to do. cmd = cmd + ['-###'] - cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env).strip() + cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env, universal_newlines=True).strip() cc_commands = [] for ln in cc_output.split('\n'): # Filter out known garbage. @@ -295,8 +295,8 @@ def form_by_frequency(symbol_lists): for a in symbols: counts[a] = counts.get(a,0) + 1 - by_count = counts.items() - by_count.sort(key = lambda (_,n): -n) + by_count = list(counts.items()) + by_count.sort(key = lambda __n: -__n[1]) return [s for s,n in by_count] def form_by_random(symbol_lists): @@ -333,14 +333,14 @@ def genOrderFile(args): help="write a list of the unordered symbols to PATH (requires --binary)", default=None, metavar="PATH") parser.add_argument("--method", dest="method", - help="order file generation method to use", choices=methods.keys(), + help="order file generation method to use", choices=list(methods.keys()), default='call_order') opts = parser.parse_args(args) # If the user gave us a binary, get all the symbols in the binary by # snarfing 'nm' output. if opts.binary_path is not None: - output = subprocess.check_output(['nm', '-P', opts.binary_path]) + output = subprocess.check_output(['nm', '-P', opts.binary_path], universal_newlines=True) lines = output.split("\n") all_symbols = [ln.split(' ',1)[0] for ln in lines diff --git a/utils/token-delta.py b/utils/token-delta.py index 327fa9221f05..62b4eb3c776c 100755 --- a/utils/token-delta.py +++ b/utils/token-delta.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import absolute_import, division, print_function import os import re import subprocess @@ -37,7 +38,7 @@ class DeltaAlgorithm(object): # O(N^2) case unless user requests it. if not force: if not self.getTestResult(changes): - raise ValueError,'Initial test passed to delta fails.' + raise ValueError('Initial test passed to delta fails.') # Check empty set first to quickly find poor test functions. if self.getTestResult(set()): @@ -94,7 +95,7 @@ class DeltaAlgorithm(object): ### -class Token: +class Token(object): def __init__(self, type, data, flags, file, line, column): self.type = type self.data = data @@ -165,7 +166,7 @@ class TMBDDelta(DeltaAlgorithm): byFile = self.writeFiles(changes, self.tempFiles) if self.log: - print >>sys.stderr, 'TEST - ', + print('TEST - ', end=' ', file=sys.stderr) if self.log > 1: for i,(file,_) in enumerate(self.tokenLists): indices = byFile[i] @@ -184,8 +185,8 @@ class TMBDDelta(DeltaAlgorithm): sys.stderr.write(str(byFile[i][-1])) sys.stderr.write('] ') else: - print >>sys.stderr, ', '.join(['%s:%d tokens' % (file, len(byFile[i])) - for i,(file,_) in enumerate(self.tokenLists)]), + print(', '.join(['%s:%d tokens' % (file, len(byFile[i])) + for i,(file,_) in enumerate(self.tokenLists)]), end=' ', file=sys.stderr) p = subprocess.Popen([self.testProgram] + self.tempFiles) res = p.wait() == 0 @@ -194,10 +195,10 @@ class TMBDDelta(DeltaAlgorithm): self.writeFiles(changes, self.targetFiles) if self.log: - print >>sys.stderr, '=> %s' % res + print('=> %s' % res, file=sys.stderr) else: if res: - print '\nSUCCESS (%d tokens)' % len(changes) + print('\nSUCCESS (%d tokens)' % len(changes)) else: sys.stderr.write('.') @@ -209,7 +210,7 @@ class TMBDDelta(DeltaAlgorithm): for j in range(len(tokens))]) self.writeFiles(res, self.targetFiles) if not self.log: - print >>sys.stderr + print(file=sys.stderr) return res def tokenBasedMultiDelta(program, files, log): @@ -218,15 +219,15 @@ def tokenBasedMultiDelta(program, files, log): for file in files] numTokens = sum([len(tokens) for _,tokens in tokenLists]) - print "Delta on %s with %d tokens." % (', '.join(files), numTokens) + print("Delta on %s with %d tokens." % (', '.join(files), numTokens)) tbmd = TMBDDelta(program, tokenLists, log) res = tbmd.run() - print "Finished %s with %d tokens (in %d tests)." % (', '.join(tbmd.targetFiles), + print("Finished %s with %d tokens (in %d tests)." % (', '.join(tbmd.targetFiles), len(res), - tbmd.numTests) + tbmd.numTests)) def main(): from optparse import OptionParser, OptionGroup @@ -247,5 +248,5 @@ if __name__ == '__main__': try: main() except KeyboardInterrupt: - print >>sys.stderr,'Interrupted.' + print('Interrupted.', file=sys.stderr) os._exit(1) # Avoid freeing our giant cache. |