slang_pragma_recorder.h revision c383a500aa59423264811be3874461bf8adbfea0
1/*
2 * Copyright 2010, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _SLANG_COMPILER_PRAGMA_HANDLER_H
18#define _SLANG_COMPILER_PRAGMA_HANDLER_H
19
20#include <list>
21#include <string>
22
23#include "clang/Lex/Pragma.h"
24
25namespace clang {
26  class Token;
27  class Preprocessor;
28}
29
30namespace slang {
31
32typedef std::list< std::pair<std::string, std::string> > PragmaList;
33
34class PragmaRecorder : public clang::PragmaHandler {
35 private:
36  PragmaList &mPragmas;
37
38  static bool GetPragmaNameFromToken(const clang::Token &Token,
39                                     std::string &PragmaName);
40
41  static bool GetPragmaValueFromToken(const clang::Token &Token,
42                                      std::string &PragmaValue);
43
44 public:
45  explicit PragmaRecorder(PragmaList &Pragmas);
46
47  virtual void HandlePragma(clang::Preprocessor &PP,
48                            clang::Token &FirstToken);
49};
50}
51
52#endif  // _SLANG_COMPILER_PRAGMA_HANDLER_H
53