From: Ted Kremenek Date: Sat, 27 Mar 2010 16:56:20 +0000 (+0000) Subject: Remove VS information for analyzer until we have more real support. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a4d77f56313cae5693c8cbd64fb13086a1b43d8;p=clang Remove VS information for analyzer until we have more real support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99720 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/www/analyzer/downloads/clangify2010.py b/www/analyzer/downloads/clangify2010.py deleted file mode 100644 index f4e656d438..0000000000 --- a/www/analyzer/downloads/clangify2010.py +++ /dev/null @@ -1,148 +0,0 @@ -# clangify2010.py - Created by Clark Gaebel [ Free as in speech. ] -# -# Python 3.x, so don't you dare 2.6 this! -# -# This script is used to generate the proper clang call from a VC/VC++ 10 -# file. As an example of this, a project with files [foo.c, bar.c, baz.c] will -# generate the command "clang --analyze foo.c bar.c baz.c" This includes C++ -# support so if we had [foo.cpp, bar.cpp, baz.cpp], it will generate the command -# "clang++ --analyze foo.cpp bar.cpp baz.cpp. -import sys -import os -from xml.dom import minidom - - -###### CUSTOMIZATION ####### - -def pre_analysis(): - ''' - Put any pre-analysis tasks in here. They will be performed before - enumeration of the project file and the actual clangification begins. - ''' - return - -def post_anlalysis(): - ''' - Put any post-analysis tasks in here, such as cleaning up from your - pre-analysis. This will be called after the actual clangification. - ''' - return - -##### END CUSTOMIZATION ##### - -def die(message): - print("ERROR: " + message) - exit() - -# returns a list of files to clang (Oh em gee I just verbed clang). -# To support other project file types, just implement a function with -# the same signature and the rest is trivial. -def parse_vs2010_project_file(filename): - output_list = list() - - file_contents = minidom.parse(filename) - elements = file_contents.getElementsByTagName('ClCompile') - - for current_element in elements: - if current_element.hasAttribute('Include'): - output_list.append(current_element.attributes['Include'].value) - - return output_list - -# returns "c" for "foo.c" -def get_file_extension(filename): - extension = str() - - for char in reversed(filename): - if char == '.': - break; - else: - extension = char + extension - - return extension - -# returns the homogenous file extension if successful, "" otherwise. -def file_extensions_are_homogenous(list_of_files): - if len(list_of_files) < 1: - return "" - - extension = get_file_extension(list_of_files[0]) - - for current_file in list_of_files: - if get_file_extension(current_file) != extension: - return "" - - return extension - -def is_in_list(lst, elem): - try: - lst.index(elem) - except ValueError: - return False - return True - -# fixes a list of files such as [foo.c, bar.c, baz.c] -# so that they are relative to a path. -# if this function is called as -# "fix_paths("./a/b/c.q", ['foo.c', 'bar.c', 'baz.c'])", -# it will return ['./a/b/foo.c', './a/b/bar.c', './a/b/baz.c'] -def fix_paths(base_filename, pathless_files): - fixed_paths = list() - for i in pathless_files: - fixed_paths.append(os.path.dirname(base_filename) + '/' + i) - return fixed_paths - -###### MAIN ###### - -pre_analysis() - -# Handle the "I don't know how to use this thing" case. -if len(sys.argv) != 2: - print( - """clangify.py - - Usage: python clangify.py [location of .vcxproj file] - - This will call clang's analysis engine on all of your C/C++ files in - the project. Please ensure that clang and clang++ are in your system - PATH. For now, this only works for VS10 project files.""") - project_file = "" -else: - project_file = sys.argv[1] - -files_to_clang = list() -if get_file_extension(project_file) == "vcxproj": - files_to_clang = parse_vs2010_project_file(project_file) -else: - die("Project file type not supported. clangify only works for VS2010.") - - -file_extension = file_extensions_are_homogenous(files_to_clang) - -clang_command = str() - -# feel free to add more extension/language support here. -c_extensions = ['c'] -cpp_extensions = ['cpp', 'cxx', 'cc'] - -if is_in_list(c_extensions, file_extension): - clang_command = 'clang --analyze' -elif is_in_list(cpp_extensions, file_extension): - clang_command = 'clang++ --analyze -ccc-clang-cxx' -elif file_extension == '': - die( - "The project's file extensions are not homogenous. Are you mixing" - ".c and .cpp files in the same project?") -else: - die( - "Unrecognized file extension. clangify/clang only support C and" - "C++ projects.") - -files_to_clang = fix_paths(project_file, files_to_clang) - -for current_file in files_to_clang: - clang_command += ' ' + current_file - -os.system(clang_command) - -post_analysis() diff --git a/www/analyzer/visual_studio.html b/www/analyzer/visual_studio.html deleted file mode 100644 index 215b71e7d2..0000000000 --- a/www/analyzer/visual_studio.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - Using the Analyzer with Visual Studio 2010 - - - - - - - -
- -
- -

clangify2010: Using the Analyzer with Visual Studio 2010

- -

The Clang Static Analyzer has only limited support right now for Visual -Studio users. Some users might find the clangify2010.py script useful -(described below) for analyzing their projects. It does not provide the same -functionality as scan-build (for example, it does not actually build -Visual Studio projects to analyze source files nor does it have a UI for viewing -results) but some users may still find it useful.

- -

We encourage anyone who is interested in developing -support/integration of the Clang Static Analyzer with Visual Studio to get -involved in clang development.

- -

Important Caveats

- -
    -
  • Clang doesn't support all Microsoft extensions implemented in Visual C/C++.
  • -
  • The Clang Static Analyzer currently has very remedial and - experimental support for analyzing C++ code. It will frequently - crash.
  • -
  • clangify2010.py strives to be as easy to read and modify as possible. If it -does not quite suit your needs, you can always tweak it to make it work the way -you want it to work.
  • -
  • This script is provided as-is. Currently no technical support - is available until we have someone to champion the development of the static - analyzer on Windows.
  • -
- -

Requirements

- -
    -
  • You have a C or C++ Visual Studio 2010 project.
  • -
  • You have Python 3.x (get the latest version here) in your PATH.
  • -
  • You have clang + llvm (get the latest version here) in your PATH. -
  • Your project does not have automatically generated intermediate files as -part of the build step. You can possibly work around this limitation by adding a -custom pre_analysis function to clangify2010.py.
  • -
  • The source files in your project all take the same compiler flags.
  • -
- -

Usage

- -

Step 1: Download the script

- -

Assuming you have met all of the above requirements, you should first -download and copy clangify2010.py to wherever your -project resides. Alternatively you can put the script in a global location and -add it to your PATH.

- -

Step 2: Running the script

- -

Once you have obtained clangify2010.py say you have a project file -called Foo.vcxproj, holding 300 .cpp files. To run the analyzer on all -these files, just type the following at the Windows command prompt:

- -
-clangify2010.py Foo.vcxproj
-
- -

clangify2010.py will automatically scan your project file for all -your C++ files and hand them off to the Clang Static Analyzer for analysis.. -Additionally, you could run the script as a post-build step to your project.

- -
-
- - -