summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2018-04-06 14:26:03 +0000
committerpatrick <patrick@openbsd.org>2018-04-06 14:26:03 +0000
commitbdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch)
treec50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py
parentPrint a 'p' flag for file descriptors that were opened after pledge(2). (diff)
downloadwireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz
wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py')
-rwxr-xr-xgnu/llvm/tools/clang/utils/analyzer/SATestAdd.py50
1 files changed, 28 insertions, 22 deletions
diff --git a/gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py b/gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py
index 4b94a109ce6..4c3e35cdcb5 100755
--- a/gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py
+++ b/gnu/llvm/tools/clang/utils/analyzer/SATestAdd.py
@@ -27,15 +27,17 @@ the Repository Directory.
- CachedSource/ - An optional directory containing the source of the
project being analyzed. If present,
download_project.sh will not be called.
- - changes_for_analyzer.patch - An optional patch file for any local changes
+ - changes_for_analyzer.patch - An optional patch file for any local
+ changes
(e.g., to adapt to newer version of clang)
that should be applied to CachedSource
before analysis. To construct this patch,
run the the download script to download
the project to CachedSource, copy the
CachedSource to another directory (for
- example, PatchedSource) and make any needed
- modifications to the the copied source.
+ example, PatchedSource) and make any
+ needed modifications to the the copied
+ source.
Then run:
diff -ur CachedSource PatchedSource \
> changes_for_analyzer.patch
@@ -46,18 +48,21 @@ import os
import csv
import sys
-def isExistingProject(PMapFile, projectID) :
+
+def isExistingProject(PMapFile, projectID):
PMapReader = csv.reader(PMapFile)
for I in PMapReader:
if projectID == I[0]:
return True
return False
-# Add a new project for testing: build it and add to the Project Map file.
-# Params:
-# Dir is the directory where the sources are.
-# ID is a short string used to identify a project.
-def addNewProject(ID, BuildMode) :
+
+def addNewProject(ID, BuildMode):
+ """
+ Add a new project for testing: build it and add to the Project Map file.
+ :param ID: is a short string used to identify a project.
+ """
+
CurDir = os.path.abspath(os.curdir)
Dir = SATestBuild.getProjectDir(ID)
if not os.path.exists(Dir):
@@ -65,36 +70,37 @@ def addNewProject(ID, BuildMode) :
sys.exit(-1)
# Build the project.
- SATestBuild.testProject(ID, BuildMode, IsReferenceBuild=True, Dir=Dir)
+ SATestBuild.testProject(ID, BuildMode, IsReferenceBuild=True)
# Add the project ID to the project map.
ProjectMapPath = os.path.join(CurDir, SATestBuild.ProjectMapFile)
+
if os.path.exists(ProjectMapPath):
- PMapFile = open(ProjectMapPath, "r+b")
+ FileMode = "r+b"
else:
print "Warning: Creating the Project Map file!!"
- PMapFile = open(ProjectMapPath, "w+b")
- try:
- if (isExistingProject(PMapFile, ID)) :
+ 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."
else:
PMapWriter = csv.writer(PMapFile)
- PMapWriter.writerow( (ID, int(BuildMode)) );
+ PMapWriter.writerow((ID, int(BuildMode)))
print "The project map is updated: ", ProjectMapPath
- finally:
- PMapFile.close()
# TODO: Add an option not to build.
# TODO: Set the path to the Repository directory.
if __name__ == '__main__':
- if len(sys.argv) < 2:
- print >> sys.stderr, 'Usage: ', sys.argv[0],\
- 'project_ID <mode>' \
- 'mode - 0 for single file project; ' \
- '1 for scan_build; ' \
+ if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):
+ print >> sys.stderr, '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'
sys.exit(-1)